Documentation ¶
Index ¶
- func RegisterTypes(typeRegistrar TypeRegistrar, zeroValues ...interface{}) error
- type Deserializer
- type Detyper
- type InterfaceDeserializer
- type InterfaceTypePrefixer
- type PrefixDeserializer
- type PrefixSerializer
- type ReaderDeserializer
- type ReflectTypePrefixer
- type Serializer
- type TypeDeserializer
- type TypePrefixer
- type TypeRegistrar
- type TypeSerializer
- type WriterSerializer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterTypes ¶
func RegisterTypes(typeRegistrar TypeRegistrar, zeroValues ...interface{}) error
RegisterTypes is a helper to register multiple types in one call.
Types ¶
type Deserializer ¶
Deserializer takes an interface and a serialization of the underlying type and populates the interface from the data.
type Detyper ¶
Detyper takes in serialized data and returns the type of the data and the rest of the data (minus the type information).
type InterfaceDeserializer ¶
InterfaceDeserializer is what is provided by the json and gob libraries, the ability to populate an interface from a byte slice.
type InterfaceTypePrefixer ¶
InterfaceTypePrefixer writes the type of the interface to slice. Generally this will end up effectivly prefixing the type.
type PrefixDeserializer ¶
type PrefixDeserializer struct { Detyper Deserializer }
PrefixDeserializer handles both deserializing the type and the data. This allows a byte slice to be passed in an the interface returned as opposed to the normal requirement of passing in both an interface and a slice.
func (PrefixDeserializer) DeserializeType ¶
func (ds PrefixDeserializer) DeserializeType(data []byte) (interface{}, error)
DeserializeType gets the type from the data, creates an instance and then deserializes the data into that instance.
type PrefixSerializer ¶
type PrefixSerializer struct { InterfaceTypePrefixer Serializer }
PrefixSerializer combines a Prefixer and a Serializer to create a TypeSerializer.
func (PrefixSerializer) SerializeType ¶
func (ps PrefixSerializer) SerializeType(i interface{}, b []byte) ([]byte, error)
SerializeType fulfills TypeSerializer using the underlying InterfaceTypePrefixer to prefix a type and the Serializer to serialize the data.
type ReaderDeserializer ¶
ReaderDeserializer serializes the provided interface to the Reader.
func (ReaderDeserializer) Deserialize ¶
func (fn ReaderDeserializer) Deserialize(i interface{}, b []byte) error
Deserialize the interface from the byte slice.
type ReflectTypePrefixer ¶
ReflectTypePrefixer writes a reflect.Type to slice. Generally this will end up effectivly prefixing the type.
type Serializer ¶
Serializer takes an interface and returns the serialization as a byte slice.
type TypeDeserializer ¶
TypeDeserializer can infer the type from the message. It can take a byte slice and return an interface containing an instance to the value represented by the serialized data.
type TypePrefixer ¶
type TypePrefixer interface { ReflectTypePrefixer InterfaceTypePrefixer }
TypePrefixer combines both TypePrefixing techniques.
func WrapPrefixer ¶
func WrapPrefixer(pre ReflectTypePrefixer) TypePrefixer
WrapPrefixer takes a ReflectTypePrefixer and wraps it with logic to add PrefixInterfaceType there by fulfilling TypePrefixer. This makes it easy to fulfill any type of prefixer by just fulfilling ReflectTypePrefixer.
type TypeRegistrar ¶
type TypeRegistrar interface {
RegisterType(zeroValue interface{}) error
}
TypeRegistrar is generally required for automatic deserialization. A zeroValue is provided (for instance a nil pointer) to register a type that can then be deserialized.
type TypeSerializer ¶
TypeSerializer takes an interface and returns the serialization as a byte slice that includes the type data.
type WriterSerializer ¶
WriterSerializer serializes the provided interface to the Writer.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package rye is a helper for writing serializing and deserializing logic.
|
Package rye is a helper for writing serializing and deserializing logic. |
wrap
|
|