github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/internal/trace/v2/raw/reader.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  // Reader parses trace bytes with only very basic validation
    16  // into an event stream.
    17  type Reader struct {
    18  	r     *bufio.Reader
    19  	v     version.Version
    20  	specs []event.Spec
    21  }
    22  
    23  // NewReader creates a new reader for the trace wire format.
    24  func NewReader(r io.Reader) (*Reader, error)
    25  
    26  // Version returns the version of the trace that we're reading.
    27  func (r *Reader) Version() version.Version
    28  
    29  // ReadEvent reads and returns the next trace event in the byte stream.
    30  func (r *Reader) ReadEvent() (Event, error)