[#168] session: Implement binary/JSON encoders/decoders on ResponseVerify

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-13 17:14:43 +03:00 committed by Alex Vanin
parent edf6ec05b3
commit 6456fcf8fa
4 changed files with 45 additions and 4 deletions

View file

@ -164,3 +164,23 @@ func (r *ResponseMetaHeader) UnmarshalJSON(data []byte) error {
return nil
}
func (r *ResponseVerificationHeader) MarshalJSON() ([]byte, error) {
return protojson.MarshalOptions{
EmitUnpopulated: true,
}.Marshal(
ResponseVerificationHeaderToGRPCMessage(r),
)
}
func (r *ResponseVerificationHeader) UnmarshalJSON(data []byte) error {
msg := new(session.ResponseVerificationHeader)
if err := protojson.Unmarshal(data, msg); err != nil {
return err
}
*r = *ResponseVerificationHeaderFromGRPCMessage(msg)
return nil
}