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

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-13 16:49:46 +03:00 committed by Alex Vanin
parent 20bf21e5e4
commit 4e163617d1
4 changed files with 45 additions and 4 deletions

View file

@ -366,6 +366,17 @@ func (t *SessionTokenBody) StableSize() (size int) {
return size
}
func (t *SessionTokenBody) Unmarshal(data []byte) error {
m := new(session.SessionToken_Body)
if err := goproto.Unmarshal(data, m); err != nil {
return err
}
*t = *SessionTokenBodyFromGRPCMessage(m)
return nil
}
func (t *SessionToken) StableMarshal(buf []byte) ([]byte, error) {
if t == nil {
return []byte{}, nil