1
1
mirror of https://github.com/wader/fq.git synced 2024-12-27 15:42:07 +03:00
fq/format/avro/decoders/bool.go
2022-01-19 19:44:42 -06:00

16 lines
397 B
Go

package decoders
import (
"github.com/wader/fq/pkg/decode"
"github.com/wader/fq/pkg/scalar"
)
func decodeBoolFn(sms ...scalar.Mapper) (DecodeFn, error) {
// A boolean is written as a single byte whose value is either 0 (false) or 1 (true).
return func(name string, d *decode.D) interface{} {
return d.FieldBoolFn(name, func(d *decode.D) bool {
return d.U8() >= 1
}, sms...)
}, nil
}