add codec.RawMessage support
All checks were successful
test / test (push) Successful in 3m53s

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2024-12-23 20:46:53 +03:00
parent 62db549d9a
commit 8e6ab14dd4
4 changed files with 31 additions and 171 deletions

View File

@@ -43,6 +43,10 @@ func (c *protoCodec) Marshal(v interface{}, opts ...codec.Option) ([]byte, error
return proto.Marshal(m)
case newproto.Message:
return proto.Marshal(m)
case codec.RawMessage:
return []byte(m), nil
case *codec.RawMessage:
return []byte(*m), nil
default:
return nil, codec.ErrInvalidMessage
}
@@ -71,6 +75,12 @@ func (c *protoCodec) Unmarshal(d []byte, v interface{}, opts ...codec.Option) er
case *pb.Frame:
m.Data = d
return nil
case *codec.RawMessage:
*m = append((*m)[0:0], d...)
return nil
case codec.RawMessage:
copy(m, d)
return nil
}
switch m := v.(type) {