add proto codec.Frame support #94

Merged
vtolstov merged 1 commits from proto-frame into v3 2023-03-05 23:47:02 +03:00
Showing only changes of commit 00c28b81e5 - Show all commits

12
xml.go
View File

@ -5,6 +5,7 @@ import (
"encoding/xml" "encoding/xml"
"io" "io"
pb "go.unistack.org/micro-proto/v3/codec"
"go.unistack.org/micro/v3/codec" "go.unistack.org/micro/v3/codec"
rutil "go.unistack.org/micro/v3/util/reflect" rutil "go.unistack.org/micro/v3/util/reflect"
) )
@ -32,7 +33,10 @@ func (c *xmlCodec) Marshal(v interface{}, opts ...codec.Option) ([]byte, error)
v = nv 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 return m.Data, nil
} }
@ -53,7 +57,11 @@ func (c *xmlCodec) Unmarshal(b []byte, v interface{}, opts ...codec.Option) erro
v = nv v = nv
} }
if m, ok := v.(*codec.Frame); ok { switch m := v.(type) {
case *codec.Frame:
m.Data = b
return nil
case *pb.Frame:
m.Data = b m.Data = b
return nil return nil
} }