Anonymous field handling for NBT

This commit is contained in:
Tnze
2023-04-26 21:51:41 +08:00
parent 9582bc2a7e
commit 078aaba156
8 changed files with 377 additions and 72 deletions

View File

@ -10,3 +10,16 @@ type Marshaler interface {
TagType() byte
MarshalNBT(w io.Writer) error
}
// FieldsUnmarshaler is a type can hold many Tags just like a TagCompound.
//
// If and only if a type which implements this interface is used as an anonymous field of a struct,
// and didn't set a struct tag, the content it holds will be considered as in the outer struct.
type FieldsUnmarshaler interface {
UnmarshalField(tagType byte, tagName string, r DecoderReader) (ok bool, err error)
}
// FieldsMarshaler is similar to FieldsUnmarshaler, but for marshaling.
type FieldsMarshaler interface {
MarshalFields(w io.Writer) (ok bool, err error)
}