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

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2024-12-23 20:42:13 +03:00
parent bfb0881b0f
commit 974847663d
4 changed files with 24 additions and 158 deletions

View File

@@ -35,6 +35,10 @@ func (c *msgpackCodec) Marshal(v interface{}, opts ...codec.Option) ([]byte, err
return m.Data, nil
case *pb.Frame:
return m.Data, nil
case codec.RawMessage:
return []byte(m), nil
case *codec.RawMessage:
return []byte(*m), nil
}
return msgpack.Marshal(v)
@@ -68,6 +72,12 @@ func (c *msgpackCodec) Unmarshal(b []byte, v interface{}, opts ...codec.Option)
case *pb.Frame:
m.Data = b
return nil
case *codec.RawMessage:
*m = append((*m)[0:0], b...)
return nil
case codec.RawMessage:
copy(m, b)
return nil
}
return msgpack.Unmarshal(b, v)