feat: better convert usage
This commit is contained in:
@@ -21,7 +21,7 @@ type forwardCodec[T, U any] struct {
|
||||
func (c forwardCodec[T, U]) Run(r Repr) (Repr, error) {
|
||||
t, ok := r.Data().(T)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("could not parse '%v' as '%s'", t, c.outType)
|
||||
return nil, fmt.Errorf("could not parse '%v' as '%s'", t, c.inType)
|
||||
}
|
||||
|
||||
u, err := c.codec.Encode(t)
|
||||
@@ -29,7 +29,7 @@ func (c forwardCodec[T, U]) Run(r Repr) (Repr, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return NewRepr(c.inType, u), nil
|
||||
return NewRepr(c.outType, u), nil
|
||||
}
|
||||
|
||||
func (c forwardCodec[T, U]) InType() string { return c.inType }
|
||||
@@ -44,7 +44,7 @@ type backwardCodec[T, U any] struct {
|
||||
func (c backwardCodec[T, U]) Run(r Repr) (Repr, error) {
|
||||
u, ok := r.Data().(U)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("could not parse '%v' as '%s'", r, c.inType)
|
||||
return nil, fmt.Errorf("could not parse '%v' as '%s'", r, c.outType)
|
||||
}
|
||||
|
||||
t, err := c.codec.Decode(u)
|
||||
@@ -52,7 +52,7 @@ func (c backwardCodec[T, U]) Run(r Repr) (Repr, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return NewRepr(c.outType, t), nil
|
||||
return NewRepr(c.inType, t), nil
|
||||
}
|
||||
|
||||
func (c backwardCodec[T, U]) InType() string { return c.outType }
|
||||
|
||||
Reference in New Issue
Block a user