package avro

import (
	
)

// Encoder writes Avro values to an output stream.
type Encoder struct {
	s Schema
	w *Writer
}

// NewEncoder returns a new encoder that writes to w using schema s.
func ( string,  io.Writer) (*Encoder, error) {
	,  := Parse()
	if  != nil {
		return nil, 
	}
	return NewEncoderForSchema(, ), nil
}

// NewEncoderForSchema returns a new encoder that writes to w using schema.
func ( Schema,  io.Writer) *Encoder {
	return DefaultConfig.NewEncoder(, )
}

// Encode writes the Avro encoding of v to the stream.
func ( *Encoder) ( any) error {
	.w.WriteVal(.s, )
	_ = .w.Flush()
	return .w.Error
}

// Marshal returns the Avro encoding of v.
func ( Schema,  any) ([]byte, error) {
	return DefaultConfig.Marshal(, )
}