[#309] pkg/session: Add marshal-unmarshal

Added Marshal, Unmarshal, MarshalJSON, UnmarshalJSON methods
to ContainerContext

Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
Angira Kekteeva 2021-06-16 22:04:14 +03:00 committed by Leonard Lyubich
parent 86d446f54c
commit 8ea9993577
2 changed files with 49 additions and 0 deletions

View file

@ -113,3 +113,27 @@ func (x *ContainerContext) ForSetEACL() {
func (x *ContainerContext) IsForSetEACL() bool {
return x.isForVerb(session.ContainerVerbSetEACL)
}
// Marshal marshals ContainerContext into a protobuf binary form.
func (x *ContainerContext) Marshal(bs ...[]byte) ([]byte, error) {
var buf []byte
if len(bs) > 0 {
buf = bs[0]
}
return x.ToV2().StableMarshal(buf)
}
// Unmarshal unmarshals protobuf binary representation of ContainerContext.
func (x *ContainerContext) Unmarshal(data []byte) error {
return x.ToV2().Unmarshal(data)
}
// MarshalJSON encodes ContainerContext to protobuf JSON format.
func (x *ContainerContext) MarshalJSON() ([]byte, error) {
return x.ToV2().MarshalJSON()
}
// UnmarshalJSON decodes ContainerContext from protobuf JSON format.
func (x *ContainerContext) UnmarshalJSON(data []byte) error {
return x.ToV2().UnmarshalJSON(data)
}