package codec type Codec interface { Decode(data []byte, out any) error Encode(data any) ([]byte, error) } func Decode[T any](c Codec, data []byte) (T, error) { var out T err := c.Decode(data, &out) return out, err } func Encode[T any](c Codec, data T) ([]byte, error) { return c.Encode(data) }