From 20ef0d92694465ac86b550df139e8366a0a2b4fa Mon Sep 17 00:00:00 2001 From: mo khan Date: Tue, 22 Jul 2025 17:35:49 -0600 Subject: feat: connect to spicedb --- vendor/github.com/hamba/avro/v2/decoder.go | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 vendor/github.com/hamba/avro/v2/decoder.go (limited to 'vendor/github.com/hamba/avro/v2/decoder.go') diff --git a/vendor/github.com/hamba/avro/v2/decoder.go b/vendor/github.com/hamba/avro/v2/decoder.go new file mode 100644 index 0000000..0e0ab9d --- /dev/null +++ b/vendor/github.com/hamba/avro/v2/decoder.go @@ -0,0 +1,49 @@ +package avro + +import ( + "io" +) + +// Decoder reads and decodes Avro values from an input stream. +type Decoder struct { + s Schema + r *Reader +} + +// NewDecoder returns a new decoder that reads from reader r using schema s. +func NewDecoder(s string, r io.Reader) (*Decoder, error) { + sch, err := Parse(s) + if err != nil { + return nil, err + } + + return NewDecoderForSchema(sch, r), nil +} + +// NewDecoderForSchema returns a new decoder that reads from r using schema. +func NewDecoderForSchema(schema Schema, reader io.Reader) *Decoder { + return DefaultConfig.NewDecoder(schema, reader) +} + +// Decode reads the next Avro encoded value from its input and stores it in the value pointed to by v. +func (d *Decoder) Decode(v any) error { + if d.r.head == d.r.tail && d.r.reader != nil { + if !d.r.loadMore() { + return io.EOF + } + } + + d.r.ReadVal(d.s, v) + + //nolint:errorlint // Only direct EOF errors should be discarded. + if d.r.Error == io.EOF { + return nil + } + return d.r.Error +} + +// Unmarshal parses the Avro encoded data and stores the result in the value pointed to by v. +// If v is nil or not a pointer, Unmarshal returns an error. +func Unmarshal(schema Schema, data []byte, v any) error { + return DefaultConfig.Unmarshal(schema, data, v) +} -- cgit v1.2.3