1
1
mirror of https://github.com/wader/fq.git synced 2024-12-01 02:30:32 +03:00
fq/format/avro/decoders/fixed.go

19 lines
494 B
Go
Raw Normal View History

2021-12-30 01:12:36 +03:00
package decoders
import (
"errors"
"github.com/wader/fq/format/avro/schema"
"github.com/wader/fq/pkg/decode"
)
func decodeFixedFn(schema schema.SimplifiedSchema) (func(string, *decode.D), error) {
if schema.Size < 0 {
return nil, errors.New("fixed size must be greater than or equal to zero")
}
size := int64(schema.Size)
//Fixed instances are encoded using the number of bytes declared in the schema.
return func(name string, d *decode.D) {
d.FieldRawLen(name, size*8)
}, nil
}