feat: marshalers to codecs
This commit is contained in:
@@ -7,16 +7,16 @@ import (
|
||||
)
|
||||
|
||||
type Registry struct {
|
||||
marshalers map[string]Marshaler
|
||||
converter *Converter
|
||||
engines map[string]Engine
|
||||
codecs map[string]Codec
|
||||
converter *Converter
|
||||
engines map[string]Engine
|
||||
}
|
||||
|
||||
func New() *Registry {
|
||||
return &Registry{
|
||||
marshalers: map[string]Marshaler{},
|
||||
converter: NewConverter(),
|
||||
engines: map[string]Engine{},
|
||||
codecs: map[string]Codec{},
|
||||
converter: NewConverter(),
|
||||
engines: map[string]Engine{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ func (r *Registry) ConvertTo(repr Repr, outType string) (Repr, error) {
|
||||
}
|
||||
|
||||
func (r *Registry) Marshal(repr Repr) (string, error) {
|
||||
m, ok := r.marshalers[repr.ID()]
|
||||
m, ok := r.codecs[repr.ID()]
|
||||
if !ok {
|
||||
return "", fmt.Errorf("no marshaler for '%s'", repr.ID())
|
||||
}
|
||||
@@ -70,7 +70,7 @@ func (r *Registry) Marshal(repr Repr) (string, error) {
|
||||
}
|
||||
|
||||
func (r *Registry) Unmarshal(s string, outType string) (Repr, error) {
|
||||
m, ok := r.marshalers[outType]
|
||||
m, ok := r.codecs[outType]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("no marshaler for '%s'", outType)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user