func (gr SetResult) encode(root *protocol.Result, s *capnp.Segment) error { r, err := protocol.NewResult_SetResult(s) if err != nil { return err } root.SubResult().SetSet(r) return nil }
func (hr HandshakeResult) encode(root *protocol.Result, s *capnp.Segment) error { r, err := protocol.NewResult_HandshakeResult(s) if err != nil { return err } r.SetClientId(hr.ClientId) root.SubResult().SetHandshake(r) return nil }
func (gr GetResult) encode(root *protocol.Result, s *capnp.Segment) error { r, err := protocol.NewResult_GetResult(s) if err != nil { return err } r.SetKey(gr.Key) r.SetValue(gr.Value) r.SetExpiry(gr.Expiry) root.SubResult().SetGet(r) return nil }
func (rs *Result) decodeHandshakeResult(msg protocol.Result) error { sub, err := msg.SubResult().Handshake() if err != nil { return err } clientId, err := sub.ClientId() if err != nil { return err } rs.SubResult = NewHandshakeResult(clientId) rs.Action = rs.SubResult.getAction() return nil }
func (rs *Result) decodeGetResult(msg protocol.Result) error { sub, err := msg.SubResult().Get() if err != nil { return err } key, err := sub.Key() if err != nil { return err } value, err := sub.Value() if err != nil { return err } expiry := sub.Expiry() rs.SubResult = NewGetResult(key, value, expiry) rs.Action = rs.SubResult.getAction() return nil }