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

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-13 16:58:08 +03:00 committed by Alex Vanin
parent 85d4713348
commit 7e3e9e1cba
4 changed files with 45 additions and 4 deletions

View file

@ -177,6 +177,17 @@ func (x *XHeader) StableSize() (size int) {
return size
}
func (x *XHeader) Unmarshal(data []byte) error {
m := new(session.XHeader)
if err := goproto.Unmarshal(data, m); err != nil {
return err
}
*x = *XHeaderFromGRPCMessage(m)
return nil
}
func (l *TokenLifetime) StableMarshal(buf []byte) ([]byte, error) {
if l == nil {
return []byte{}, nil