// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package raw

import (
	
	

	
)

// TextWriter emits the text format of a trace.
type TextWriter struct {
	w io.Writer
	v version.Version
}

// NewTextWriter creates a new write for the trace text format.
func ( io.Writer,  version.Version) (*TextWriter, error) {
	,  := fmt.Fprintf(, "Trace Go1.%d\n", )
	if  != nil {
		return nil, 
	}
	return &TextWriter{w: , v: }, nil
}

// WriteEvent writes a single event to the stream.
func ( *TextWriter) ( Event) error {
	// Check version.
	if .Version != .v {
		return fmt.Errorf("mismatched version between writer (go 1.%d) and event (go 1.%d)", .v, .Version)
	}

	// Write event.
	,  := fmt.Fprintln(.w, .String())
	return 
}