Documentation ¶
Index ¶
- func Deserialize(serializer Serializer, typeName string, r io.Reader) (any, error)
- func DeserializeFromText(serializer Serializer, typeName string, text string) (any, error)
- func GetType(typeName string) (reflect.Type, error)
- func Map[T any]()
- func NewFromTypeName(typeName string) (reflect.Value, error)
- func Serialize(serializer Serializer, r io.Writer, v any) error
- func SerializeToText(serializer Serializer, v any) (string, error)
- type BinarySerializer
- type GobSerializer
- type JsonSerializer
- type Serializable
- type Serializer
- type TextSerializer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Deserialize ¶
func DeserializeFromText ¶
func DeserializeFromText(serializer Serializer, typeName string, text string) (any, error)
func Map ¶
func Map[T any]()
Map struct type to type's name.
Use T.TypeName() as type's name if T implements interface{TypeName() string}, else use struct type's name. Thread unsafe, should be invoked at startup.
func NewFromTypeName ¶
NewFromTypeName to new struct value that has mapped by type name.
func SerializeToText ¶
func SerializeToText(serializer Serializer, v any) (string, error)
Types ¶
type BinarySerializer ¶
type BinarySerializer interface { Serializer BinarySerializer() }
func DefaultBinary ¶
func DefaultBinary() BinarySerializer
type GobSerializer ¶
type GobSerializer struct { }
func (*GobSerializer) BinarySerializer ¶
func (s *GobSerializer) BinarySerializer()
func (*GobSerializer) Deserialize ¶
func (s *GobSerializer) Deserialize(r io.Reader, v any) error
type JsonSerializer ¶
type JsonSerializer struct { }
func (*JsonSerializer) Deserialize ¶
func (s *JsonSerializer) Deserialize(r io.Reader, v any) error
func (*JsonSerializer) TextSerializer ¶
func (s *JsonSerializer) TextSerializer()
type Serializable ¶
type Serializable interface {
TypeName() string
}
type Serializer ¶
type TextSerializer ¶
type TextSerializer interface { Serializer TextSerializer() }
func DefaultText ¶
func DefaultText() TextSerializer
Click to show internal directories.
Click to hide internal directories.