Palette support 1

This commit is contained in:
Tnze
2021-12-17 18:45:06 +08:00
parent ee33cedd79
commit 70b0fbf1b7
12 changed files with 2481 additions and 17 deletions

View File

@ -78,6 +78,20 @@ func (a Ary) ReadFrom(r io.Reader) (n int64, err error) {
return n, err
}
// Array return an Ary but handled the previous Length field
//
// Warning: unstable API, may change in later version
func Array(array interface{}) Field {
length := VarInt(reflect.ValueOf(array).Len())
return Tuple{
&length,
Ary{
Len: &length,
Ary: array,
},
}
}
type Opt struct {
Has interface{} // Pointer of bool, or `func() bool`
Field interface{} // FieldEncoder, FieldDecoder or both (Field)