2021-12-30 01:12:36 +03:00
|
|
|
package decoders
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/wader/fq/pkg/decode"
|
2022-01-14 08:32:19 +03:00
|
|
|
"github.com/wader/fq/pkg/scalar"
|
2021-12-30 01:12:36 +03:00
|
|
|
)
|
|
|
|
|
2022-01-20 04:44:42 +03:00
|
|
|
func decodeBoolFn(sms ...scalar.Mapper) (DecodeFn, error) {
|
2022-01-14 08:32:19 +03:00
|
|
|
// 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 {
|
2021-12-30 01:12:36 +03:00
|
|
|
return d.U8() >= 1
|
2022-01-20 04:44:42 +03:00
|
|
|
}, sms...)
|
2021-12-30 01:12:36 +03:00
|
|
|
}, nil
|
|
|
|
}
|