Documentation ¶
Index ¶
- func New() *registry
- func Register(reg Registry, v Registrable, s Serializer, d Deserializer, os []BuildOption) error
- func RegisterFactory(reg Registry, key string, fn func() interface{}, s Serializer, d Deserializer, ...) error
- func RegisterKey(reg Registry, key string, v interface{}, s Serializer, d Deserializer, ...) error
- type AlreadyRegisteredKey
- type BuildOption
- type Deserializer
- type Registrable
- type Registry
- type Serde
- type Serializer
- type UnregisteredKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(reg Registry, v Registrable, s Serializer, d Deserializer, os []BuildOption) error
func RegisterFactory ¶
func RegisterFactory(reg Registry, key string, fn func() interface{}, s Serializer, d Deserializer, os []BuildOption, ) error
func RegisterKey ¶
func RegisterKey(reg Registry, key string, v interface{}, s Serializer, d Deserializer, os []BuildOption) error
Types ¶
type AlreadyRegisteredKey ¶
type AlreadyRegisteredKey string
func (AlreadyRegisteredKey) Error ¶
func (key AlreadyRegisteredKey) Error() string
type BuildOption ¶
type BuildOption func(v interface{}) error
func ValidateImplements ¶
func ValidateImplements(checkV interface{}) BuildOption
ValidateImplements will verify that the built value implements the given interface
Pass interfaces using "(*I)(nil)", like in this example:
type MyInterface interface { MyMethod(int) bool } ValidateImplements((*MyInterface)(nil))
You will only be able to validate interfaces with exported methods, you will not be able to validate any that have one or more unexported methods.
type Deserializer ¶
type Registrable ¶
type Registrable interface {
Key() string
}
type Registry ¶
type Registry interface { Serialize(key string, v interface{}) ([]byte, error) MustSerialize(key string, v interface{}) []byte Build(key string, options ...BuildOption) (interface{}, error) MustBuild(key string, options ...BuildOption) interface{} Deserialize(key string, data []byte, options ...BuildOption) (interface{}, error) MustDeserialize(key string, data []byte, options ...BuildOption) interface{} // contains filtered or unexported methods }
type Serde ¶
type Serde interface { Register(v Registrable, options ...BuildOption) error RegisterKey(key string, v interface{}, options ...BuildOption) error RegisterFactory(key string, fn func() interface{}, options ...BuildOption) error }
type Serializer ¶
type UnregisteredKey ¶
type UnregisteredKey string
func (UnregisteredKey) Error ¶
func (key UnregisteredKey) Error() string
Source Files ¶
Click to show internal directories.
Click to hide internal directories.