Documentation
¶
Index ¶
Constants ¶
View Source
const (
// DefaultTagName that enables serialization.
DefaultTagName = "serialize"
)
View Source
const TagValue = "true"
TagValue is the value the tag must have to be serialized.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type StructFielder ¶
type StructFielder interface {
// Returns the fields that have been marked as serializable in [t], which is
// a struct type.
// Returns an error if a field has tag "[tagName]: [TagValue]" but the field
// is un-exported.
// GetSerializedField(Foo) --> [1,5,8] means Foo.Field(1), Foo.Field(5),
// Foo.Field(8) are to be serialized/deserialized.
GetSerializedFields(t reflect.Type) ([]int, error)
}
StructFielder handles discovery of serializable fields in a struct.
func NewStructFielder ¶
func NewStructFielder(tagNames []string) StructFielder
type TypeCodec ¶
type TypeCodec interface {
// UnpackPrefix unpacks the prefix of an interface from the given packer.
// The prefix specifies the concrete type that the interface should be
// deserialized into. This function returns a new instance of that concrete
// type. The concrete type must implement the given type.
UnpackPrefix(*wrappers.Packer, reflect.Type) (reflect.Value, error)
// PackPrefix packs the prefix for the given type into the given packer.
// This identifies the bytes that follow, which are the byte representation
// of an interface, as having the given concrete type.
// When deserializing the bytes, the prefix specifies which concrete type
// to deserialize into.
PackPrefix(*wrappers.Packer, reflect.Type) error
// PrefixSize returns prefix length for the given type into the given
// packer.
PrefixSize(reflect.Type) int
}
Click to show internal directories.
Click to hide internal directories.