github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/internal/trace/v2/raw/textreader.go (about) 1 // Copyright 2023 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package raw 6 7 import ( 8 "github.com/shogo82148/std/bufio" 9 "github.com/shogo82148/std/io" 10 11 "github.com/shogo82148/std/internal/trace/v2/event" 12 "github.com/shogo82148/std/internal/trace/v2/version" 13 ) 14 15 // TextReader parses a text format trace with only very basic validation 16 // into an event stream. 17 type TextReader struct { 18 v version.Version 19 specs []event.Spec 20 names map[string]event.Type 21 s *bufio.Scanner 22 } 23 24 // NewTextReader creates a new reader for the trace text format. 25 func NewTextReader(r io.Reader) (*TextReader, error) 26 27 // Version returns the version of the trace that we're reading. 28 func (r *TextReader) Version() version.Version 29 30 // ReadEvent reads and returns the next trace event in the text stream. 31 func (r *TextReader) ReadEvent() (Event, error)