add proto codec.Frame support

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2023-03-05 22:20:00 +03:00
parent 09352c9404
commit 0056cc9490
2 changed files with 16 additions and 5 deletions

View File

@@ -4,6 +4,7 @@ package proto // import "go.unistack.org/micro-codec-proto/v3"
import (
"io"
pb "go.unistack.org/micro-proto/v3/codec"
"go.unistack.org/micro/v3/codec"
rutil "go.unistack.org/micro/v3/util/reflect"
"google.golang.org/protobuf/proto"
@@ -33,7 +34,10 @@ func (c *protoCodec) Marshal(v interface{}, opts ...codec.Option) ([]byte, error
v = nv
}
if m, ok := v.(*codec.Frame); ok {
switch m := v.(type) {
case *codec.Frame:
return m.Data, nil
case *pb.Frame:
return m.Data, nil
}
@@ -58,7 +62,11 @@ func (c *protoCodec) Unmarshal(d []byte, v interface{}, opts ...codec.Option) er
v = nv
}
if m, ok := v.(*codec.Frame); ok {
switch m := v.(type) {
case *codec.Frame:
m.Data = d
return nil
case *pb.Frame:
m.Data = d
return nil
}