You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
715 B
Go
38 lines
715 B
Go
package ndef
|
|
|
|
type (
|
|
MarshalFunc func(v any) ([]byte, error)
|
|
UnmarshalFunc func(data []byte, v any) error
|
|
|
|
Marshaler interface {
|
|
Marshal(v any) ([]byte, error)
|
|
}
|
|
|
|
Unmarshaler interface {
|
|
Unmarshal(data []byte, v any) error
|
|
}
|
|
|
|
Serializer interface {
|
|
Marshaler
|
|
Unmarshaler
|
|
}
|
|
)
|
|
|
|
type (
|
|
MarshalerWrapper struct {
|
|
Marshaler
|
|
}
|
|
UnmarshalerWrapper struct {
|
|
Unmarshaler
|
|
}
|
|
SerializerWrapper struct {
|
|
Marshaler
|
|
Unmarshaler
|
|
}
|
|
)
|
|
|
|
// NewSerializerWrapper 序列化器包装,用于将序列化/反序列化包装为一个独立结构
|
|
func NewSerializerWrapper(marshaler Marshaler, unmarshaler Unmarshaler) Serializer {
|
|
return &SerializerWrapper{Marshaler: marshaler, Unmarshaler: unmarshaler}
|
|
}
|