micro-client-drpc/codec.go
Vasiliy Tolstov 69be182d92 update import paths
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2021-10-27 18:13:33 +03:00

27 lines
516 B
Go

package drpc
import (
"go.unistack.org/micro/v3/codec"
"storj.io/drpc"
)
type wrapMicroCodec struct{ codec.Codec }
func (w *wrapMicroCodec) Marshal(v drpc.Message) ([]byte, error) {
if m, ok := v.(*codec.Frame); ok {
return m.Data, nil
}
return w.Codec.Marshal(v.(interface{}))
}
func (w *wrapMicroCodec) Unmarshal(d []byte, v drpc.Message) error {
if d == nil || v == nil {
return nil
}
if m, ok := v.(*codec.Frame); ok {
m.Data = d
return nil
}
return w.Codec.Unmarshal(d, v.(interface{}))
}