feat: marshalers to codecs

This commit is contained in:
2026-02-07 00:36:05 -05:00
parent b61ca744e0
commit 30382bee7e
9 changed files with 79 additions and 107 deletions

View File

@@ -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)
}