forked from TrueCloudLab/frostfs-api-go
[#168] refs: Implement binary/JSON encoders/decoders on OwnerID
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
c0f3ac51d4
commit
9ec57ee9f8
6 changed files with 110 additions and 6 deletions
|
@ -64,3 +64,23 @@ func (c *ContainerID) UnmarshalJSON(data []byte) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *OwnerID) MarshalJSON() ([]byte, error) {
|
||||
return protojson.MarshalOptions{
|
||||
EmitUnpopulated: true,
|
||||
}.Marshal(
|
||||
OwnerIDToGRPCMessage(o),
|
||||
)
|
||||
}
|
||||
|
||||
func (o *OwnerID) UnmarshalJSON(data []byte) error {
|
||||
msg := new(refs.OwnerID)
|
||||
|
||||
if err := protojson.Unmarshal(data, msg); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*o = *OwnerIDFromGRPCMessage(msg)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue