1397 lines
34 KiB
Go
1397 lines
34 KiB
Go
// Code generated by ogen, DO NOT EDIT.
|
|
|
|
package gsn
|
|
|
|
import (
|
|
"math/bits"
|
|
"strconv"
|
|
|
|
"github.com/go-faster/errors"
|
|
"github.com/go-faster/jx"
|
|
|
|
"github.com/ogen-go/ogen/json"
|
|
"github.com/ogen-go/ogen/validate"
|
|
)
|
|
|
|
// Encode implements json.Marshaler.
|
|
func (s *Error) Encode(e *jx.Encoder) {
|
|
e.ObjStart()
|
|
s.encodeFields(e)
|
|
e.ObjEnd()
|
|
}
|
|
|
|
// encodeFields encodes fields.
|
|
func (s *Error) encodeFields(e *jx.Encoder) {
|
|
{
|
|
e.FieldStart("message")
|
|
e.Str(s.Message)
|
|
}
|
|
{
|
|
if s.Details.Set {
|
|
e.FieldStart("details")
|
|
s.Details.Encode(e)
|
|
}
|
|
}
|
|
}
|
|
|
|
var jsonFieldsNameOfError = [2]string{
|
|
0: "message",
|
|
1: "details",
|
|
}
|
|
|
|
// Decode decodes Error from json.
|
|
func (s *Error) Decode(d *jx.Decoder) error {
|
|
if s == nil {
|
|
return errors.New("invalid: unable to decode Error to nil")
|
|
}
|
|
var requiredBitSet [1]uint8
|
|
|
|
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
|
switch string(k) {
|
|
case "message":
|
|
requiredBitSet[0] |= 1 << 0
|
|
if err := func() error {
|
|
v, err := d.Str()
|
|
s.Message = string(v)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return errors.Wrap(err, "decode field \"message\"")
|
|
}
|
|
case "details":
|
|
if err := func() error {
|
|
s.Details.Reset()
|
|
if err := s.Details.Decode(d); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return errors.Wrap(err, "decode field \"details\"")
|
|
}
|
|
default:
|
|
return d.Skip()
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return errors.Wrap(err, "decode Error")
|
|
}
|
|
// Validate required fields.
|
|
var failures []validate.FieldError
|
|
for i, mask := range [1]uint8{
|
|
0b00000001,
|
|
} {
|
|
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
|
// Mask only required fields and check equality to mask using XOR.
|
|
//
|
|
// If XOR result is not zero, result is not equal to expected, so some fields are missed.
|
|
// Bits of fields which would be set are actually bits of missed fields.
|
|
missed := bits.OnesCount8(result)
|
|
for bitN := 0; bitN < missed; bitN++ {
|
|
bitIdx := bits.TrailingZeros8(result)
|
|
fieldIdx := i*8 + bitIdx
|
|
var name string
|
|
if fieldIdx < len(jsonFieldsNameOfError) {
|
|
name = jsonFieldsNameOfError[fieldIdx]
|
|
} else {
|
|
name = strconv.Itoa(fieldIdx)
|
|
}
|
|
failures = append(failures, validate.FieldError{
|
|
Name: name,
|
|
Error: validate.ErrFieldRequired,
|
|
})
|
|
// Reset bit.
|
|
result &^= 1 << bitIdx
|
|
}
|
|
}
|
|
}
|
|
if len(failures) > 0 {
|
|
return &validate.Error{Fields: failures}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalJSON implements stdjson.Marshaler.
|
|
func (s *Error) MarshalJSON() ([]byte, error) {
|
|
e := jx.Encoder{}
|
|
s.Encode(&e)
|
|
return e.Bytes(), nil
|
|
}
|
|
|
|
// UnmarshalJSON implements stdjson.Unmarshaler.
|
|
func (s *Error) UnmarshalJSON(data []byte) error {
|
|
d := jx.DecodeBytes(data)
|
|
return s.Decode(d)
|
|
}
|
|
|
|
// Encode implements json.Marshaler.
|
|
func (s *GetSatellitesOK) Encode(e *jx.Encoder) {
|
|
e.ObjStart()
|
|
s.encodeFields(e)
|
|
e.ObjEnd()
|
|
}
|
|
|
|
// encodeFields encodes fields.
|
|
func (s *GetSatellitesOK) encodeFields(e *jx.Encoder) {
|
|
{
|
|
if s.Satellites != nil {
|
|
e.FieldStart("satellites")
|
|
e.ArrStart()
|
|
for _, elem := range s.Satellites {
|
|
elem.Encode(e)
|
|
}
|
|
e.ArrEnd()
|
|
}
|
|
}
|
|
}
|
|
|
|
var jsonFieldsNameOfGetSatellitesOK = [1]string{
|
|
0: "satellites",
|
|
}
|
|
|
|
// Decode decodes GetSatellitesOK from json.
|
|
func (s *GetSatellitesOK) Decode(d *jx.Decoder) error {
|
|
if s == nil {
|
|
return errors.New("invalid: unable to decode GetSatellitesOK to nil")
|
|
}
|
|
|
|
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
|
switch string(k) {
|
|
case "satellites":
|
|
if err := func() error {
|
|
s.Satellites = make([]GetSatellitesOKSatellitesItem, 0)
|
|
if err := d.Arr(func(d *jx.Decoder) error {
|
|
var elem GetSatellitesOKSatellitesItem
|
|
if err := elem.Decode(d); err != nil {
|
|
return err
|
|
}
|
|
s.Satellites = append(s.Satellites, elem)
|
|
return nil
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return errors.Wrap(err, "decode field \"satellites\"")
|
|
}
|
|
default:
|
|
return d.Skip()
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return errors.Wrap(err, "decode GetSatellitesOK")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalJSON implements stdjson.Marshaler.
|
|
func (s *GetSatellitesOK) MarshalJSON() ([]byte, error) {
|
|
e := jx.Encoder{}
|
|
s.Encode(&e)
|
|
return e.Bytes(), nil
|
|
}
|
|
|
|
// UnmarshalJSON implements stdjson.Unmarshaler.
|
|
func (s *GetSatellitesOK) UnmarshalJSON(data []byte) error {
|
|
d := jx.DecodeBytes(data)
|
|
return s.Decode(d)
|
|
}
|
|
|
|
// Encode implements json.Marshaler.
|
|
func (s *GetSatellitesOKSatellitesItem) Encode(e *jx.Encoder) {
|
|
e.ObjStart()
|
|
s.encodeFields(e)
|
|
e.ObjEnd()
|
|
}
|
|
|
|
// encodeFields encodes fields.
|
|
func (s *GetSatellitesOKSatellitesItem) encodeFields(e *jx.Encoder) {
|
|
{
|
|
e.FieldStart("id")
|
|
json.EncodeUUID(e, s.ID)
|
|
}
|
|
{
|
|
e.FieldStart("display_name")
|
|
e.Str(s.DisplayName)
|
|
}
|
|
{
|
|
e.FieldStart("status")
|
|
s.Status.Encode(e)
|
|
}
|
|
}
|
|
|
|
var jsonFieldsNameOfGetSatellitesOKSatellitesItem = [3]string{
|
|
0: "id",
|
|
1: "display_name",
|
|
2: "status",
|
|
}
|
|
|
|
// Decode decodes GetSatellitesOKSatellitesItem from json.
|
|
func (s *GetSatellitesOKSatellitesItem) Decode(d *jx.Decoder) error {
|
|
if s == nil {
|
|
return errors.New("invalid: unable to decode GetSatellitesOKSatellitesItem to nil")
|
|
}
|
|
var requiredBitSet [1]uint8
|
|
|
|
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
|
switch string(k) {
|
|
case "id":
|
|
requiredBitSet[0] |= 1 << 0
|
|
if err := func() error {
|
|
v, err := json.DecodeUUID(d)
|
|
s.ID = v
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return errors.Wrap(err, "decode field \"id\"")
|
|
}
|
|
case "display_name":
|
|
requiredBitSet[0] |= 1 << 1
|
|
if err := func() error {
|
|
v, err := d.Str()
|
|
s.DisplayName = string(v)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return errors.Wrap(err, "decode field \"display_name\"")
|
|
}
|
|
case "status":
|
|
requiredBitSet[0] |= 1 << 2
|
|
if err := func() error {
|
|
if err := s.Status.Decode(d); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return errors.Wrap(err, "decode field \"status\"")
|
|
}
|
|
default:
|
|
return d.Skip()
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return errors.Wrap(err, "decode GetSatellitesOKSatellitesItem")
|
|
}
|
|
// Validate required fields.
|
|
var failures []validate.FieldError
|
|
for i, mask := range [1]uint8{
|
|
0b00000111,
|
|
} {
|
|
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
|
// Mask only required fields and check equality to mask using XOR.
|
|
//
|
|
// If XOR result is not zero, result is not equal to expected, so some fields are missed.
|
|
// Bits of fields which would be set are actually bits of missed fields.
|
|
missed := bits.OnesCount8(result)
|
|
for bitN := 0; bitN < missed; bitN++ {
|
|
bitIdx := bits.TrailingZeros8(result)
|
|
fieldIdx := i*8 + bitIdx
|
|
var name string
|
|
if fieldIdx < len(jsonFieldsNameOfGetSatellitesOKSatellitesItem) {
|
|
name = jsonFieldsNameOfGetSatellitesOKSatellitesItem[fieldIdx]
|
|
} else {
|
|
name = strconv.Itoa(fieldIdx)
|
|
}
|
|
failures = append(failures, validate.FieldError{
|
|
Name: name,
|
|
Error: validate.ErrFieldRequired,
|
|
})
|
|
// Reset bit.
|
|
result &^= 1 << bitIdx
|
|
}
|
|
}
|
|
}
|
|
if len(failures) > 0 {
|
|
return &validate.Error{Fields: failures}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalJSON implements stdjson.Marshaler.
|
|
func (s *GetSatellitesOKSatellitesItem) MarshalJSON() ([]byte, error) {
|
|
e := jx.Encoder{}
|
|
s.Encode(&e)
|
|
return e.Bytes(), nil
|
|
}
|
|
|
|
// UnmarshalJSON implements stdjson.Unmarshaler.
|
|
func (s *GetSatellitesOKSatellitesItem) UnmarshalJSON(data []byte) error {
|
|
d := jx.DecodeBytes(data)
|
|
return s.Decode(d)
|
|
}
|
|
|
|
// Encode encodes GetSatellitesOKSatellitesItemStatus as json.
|
|
func (s GetSatellitesOKSatellitesItemStatus) Encode(e *jx.Encoder) {
|
|
e.Str(string(s))
|
|
}
|
|
|
|
// Decode decodes GetSatellitesOKSatellitesItemStatus from json.
|
|
func (s *GetSatellitesOKSatellitesItemStatus) Decode(d *jx.Decoder) error {
|
|
if s == nil {
|
|
return errors.New("invalid: unable to decode GetSatellitesOKSatellitesItemStatus to nil")
|
|
}
|
|
v, err := d.StrBytes()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Try to use constant string.
|
|
switch GetSatellitesOKSatellitesItemStatus(v) {
|
|
case GetSatellitesOKSatellitesItemStatusActive:
|
|
*s = GetSatellitesOKSatellitesItemStatusActive
|
|
case GetSatellitesOKSatellitesItemStatusOffline:
|
|
*s = GetSatellitesOKSatellitesItemStatusOffline
|
|
case GetSatellitesOKSatellitesItemStatusBusy:
|
|
*s = GetSatellitesOKSatellitesItemStatusBusy
|
|
default:
|
|
*s = GetSatellitesOKSatellitesItemStatus(v)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalJSON implements stdjson.Marshaler.
|
|
func (s GetSatellitesOKSatellitesItemStatus) MarshalJSON() ([]byte, error) {
|
|
e := jx.Encoder{}
|
|
s.Encode(&e)
|
|
return e.Bytes(), nil
|
|
}
|
|
|
|
// UnmarshalJSON implements stdjson.Unmarshaler.
|
|
func (s *GetSatellitesOKSatellitesItemStatus) UnmarshalJSON(data []byte) error {
|
|
d := jx.DecodeBytes(data)
|
|
return s.Decode(d)
|
|
}
|
|
|
|
// Encode implements json.Marshaler.
|
|
func (s *GetStationsOK) Encode(e *jx.Encoder) {
|
|
e.ObjStart()
|
|
s.encodeFields(e)
|
|
e.ObjEnd()
|
|
}
|
|
|
|
// encodeFields encodes fields.
|
|
func (s *GetStationsOK) encodeFields(e *jx.Encoder) {
|
|
{
|
|
e.FieldStart("stations")
|
|
e.ArrStart()
|
|
for _, elem := range s.Stations {
|
|
elem.Encode(e)
|
|
}
|
|
e.ArrEnd()
|
|
}
|
|
}
|
|
|
|
var jsonFieldsNameOfGetStationsOK = [1]string{
|
|
0: "stations",
|
|
}
|
|
|
|
// Decode decodes GetStationsOK from json.
|
|
func (s *GetStationsOK) Decode(d *jx.Decoder) error {
|
|
if s == nil {
|
|
return errors.New("invalid: unable to decode GetStationsOK to nil")
|
|
}
|
|
var requiredBitSet [1]uint8
|
|
|
|
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
|
switch string(k) {
|
|
case "stations":
|
|
requiredBitSet[0] |= 1 << 0
|
|
if err := func() error {
|
|
s.Stations = make([]GetStationsOKStationsItem, 0)
|
|
if err := d.Arr(func(d *jx.Decoder) error {
|
|
var elem GetStationsOKStationsItem
|
|
if err := elem.Decode(d); err != nil {
|
|
return err
|
|
}
|
|
s.Stations = append(s.Stations, elem)
|
|
return nil
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return errors.Wrap(err, "decode field \"stations\"")
|
|
}
|
|
default:
|
|
return d.Skip()
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return errors.Wrap(err, "decode GetStationsOK")
|
|
}
|
|
// Validate required fields.
|
|
var failures []validate.FieldError
|
|
for i, mask := range [1]uint8{
|
|
0b00000001,
|
|
} {
|
|
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
|
// Mask only required fields and check equality to mask using XOR.
|
|
//
|
|
// If XOR result is not zero, result is not equal to expected, so some fields are missed.
|
|
// Bits of fields which would be set are actually bits of missed fields.
|
|
missed := bits.OnesCount8(result)
|
|
for bitN := 0; bitN < missed; bitN++ {
|
|
bitIdx := bits.TrailingZeros8(result)
|
|
fieldIdx := i*8 + bitIdx
|
|
var name string
|
|
if fieldIdx < len(jsonFieldsNameOfGetStationsOK) {
|
|
name = jsonFieldsNameOfGetStationsOK[fieldIdx]
|
|
} else {
|
|
name = strconv.Itoa(fieldIdx)
|
|
}
|
|
failures = append(failures, validate.FieldError{
|
|
Name: name,
|
|
Error: validate.ErrFieldRequired,
|
|
})
|
|
// Reset bit.
|
|
result &^= 1 << bitIdx
|
|
}
|
|
}
|
|
}
|
|
if len(failures) > 0 {
|
|
return &validate.Error{Fields: failures}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalJSON implements stdjson.Marshaler.
|
|
func (s *GetStationsOK) MarshalJSON() ([]byte, error) {
|
|
e := jx.Encoder{}
|
|
s.Encode(&e)
|
|
return e.Bytes(), nil
|
|
}
|
|
|
|
// UnmarshalJSON implements stdjson.Unmarshaler.
|
|
func (s *GetStationsOK) UnmarshalJSON(data []byte) error {
|
|
d := jx.DecodeBytes(data)
|
|
return s.Decode(d)
|
|
}
|
|
|
|
// Encode implements json.Marshaler.
|
|
func (s *GetStationsOKStationsItem) Encode(e *jx.Encoder) {
|
|
e.ObjStart()
|
|
s.encodeFields(e)
|
|
e.ObjEnd()
|
|
}
|
|
|
|
// encodeFields encodes fields.
|
|
func (s *GetStationsOKStationsItem) encodeFields(e *jx.Encoder) {
|
|
{
|
|
e.FieldStart("id")
|
|
json.EncodeUUID(e, s.ID)
|
|
}
|
|
{
|
|
e.FieldStart("slug")
|
|
e.Str(s.Slug)
|
|
}
|
|
{
|
|
e.FieldStart("status")
|
|
s.Status.Encode(e)
|
|
}
|
|
}
|
|
|
|
var jsonFieldsNameOfGetStationsOKStationsItem = [3]string{
|
|
0: "id",
|
|
1: "slug",
|
|
2: "status",
|
|
}
|
|
|
|
// Decode decodes GetStationsOKStationsItem from json.
|
|
func (s *GetStationsOKStationsItem) Decode(d *jx.Decoder) error {
|
|
if s == nil {
|
|
return errors.New("invalid: unable to decode GetStationsOKStationsItem to nil")
|
|
}
|
|
var requiredBitSet [1]uint8
|
|
|
|
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
|
switch string(k) {
|
|
case "id":
|
|
requiredBitSet[0] |= 1 << 0
|
|
if err := func() error {
|
|
v, err := json.DecodeUUID(d)
|
|
s.ID = v
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return errors.Wrap(err, "decode field \"id\"")
|
|
}
|
|
case "slug":
|
|
requiredBitSet[0] |= 1 << 1
|
|
if err := func() error {
|
|
v, err := d.Str()
|
|
s.Slug = string(v)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return errors.Wrap(err, "decode field \"slug\"")
|
|
}
|
|
case "status":
|
|
requiredBitSet[0] |= 1 << 2
|
|
if err := func() error {
|
|
if err := s.Status.Decode(d); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return errors.Wrap(err, "decode field \"status\"")
|
|
}
|
|
default:
|
|
return d.Skip()
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return errors.Wrap(err, "decode GetStationsOKStationsItem")
|
|
}
|
|
// Validate required fields.
|
|
var failures []validate.FieldError
|
|
for i, mask := range [1]uint8{
|
|
0b00000111,
|
|
} {
|
|
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
|
// Mask only required fields and check equality to mask using XOR.
|
|
//
|
|
// If XOR result is not zero, result is not equal to expected, so some fields are missed.
|
|
// Bits of fields which would be set are actually bits of missed fields.
|
|
missed := bits.OnesCount8(result)
|
|
for bitN := 0; bitN < missed; bitN++ {
|
|
bitIdx := bits.TrailingZeros8(result)
|
|
fieldIdx := i*8 + bitIdx
|
|
var name string
|
|
if fieldIdx < len(jsonFieldsNameOfGetStationsOKStationsItem) {
|
|
name = jsonFieldsNameOfGetStationsOKStationsItem[fieldIdx]
|
|
} else {
|
|
name = strconv.Itoa(fieldIdx)
|
|
}
|
|
failures = append(failures, validate.FieldError{
|
|
Name: name,
|
|
Error: validate.ErrFieldRequired,
|
|
})
|
|
// Reset bit.
|
|
result &^= 1 << bitIdx
|
|
}
|
|
}
|
|
}
|
|
if len(failures) > 0 {
|
|
return &validate.Error{Fields: failures}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalJSON implements stdjson.Marshaler.
|
|
func (s *GetStationsOKStationsItem) MarshalJSON() ([]byte, error) {
|
|
e := jx.Encoder{}
|
|
s.Encode(&e)
|
|
return e.Bytes(), nil
|
|
}
|
|
|
|
// UnmarshalJSON implements stdjson.Unmarshaler.
|
|
func (s *GetStationsOKStationsItem) UnmarshalJSON(data []byte) error {
|
|
d := jx.DecodeBytes(data)
|
|
return s.Decode(d)
|
|
}
|
|
|
|
// Encode encodes GetStationsOKStationsItemStatus as json.
|
|
func (s GetStationsOKStationsItemStatus) Encode(e *jx.Encoder) {
|
|
e.Str(string(s))
|
|
}
|
|
|
|
// Decode decodes GetStationsOKStationsItemStatus from json.
|
|
func (s *GetStationsOKStationsItemStatus) Decode(d *jx.Decoder) error {
|
|
if s == nil {
|
|
return errors.New("invalid: unable to decode GetStationsOKStationsItemStatus to nil")
|
|
}
|
|
v, err := d.StrBytes()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Try to use constant string.
|
|
switch GetStationsOKStationsItemStatus(v) {
|
|
case GetStationsOKStationsItemStatusActive:
|
|
*s = GetStationsOKStationsItemStatusActive
|
|
case GetStationsOKStationsItemStatusOffline:
|
|
*s = GetStationsOKStationsItemStatusOffline
|
|
case GetStationsOKStationsItemStatusBusy:
|
|
*s = GetStationsOKStationsItemStatusBusy
|
|
default:
|
|
*s = GetStationsOKStationsItemStatus(v)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalJSON implements stdjson.Marshaler.
|
|
func (s GetStationsOKStationsItemStatus) MarshalJSON() ([]byte, error) {
|
|
e := jx.Encoder{}
|
|
s.Encode(&e)
|
|
return e.Bytes(), nil
|
|
}
|
|
|
|
// UnmarshalJSON implements stdjson.Unmarshaler.
|
|
func (s *GetStationsOKStationsItemStatus) UnmarshalJSON(data []byte) error {
|
|
d := jx.DecodeBytes(data)
|
|
return s.Decode(d)
|
|
}
|
|
|
|
// Encode implements json.Marshaler.
|
|
func (s *GetSubscriptionsOK) Encode(e *jx.Encoder) {
|
|
e.ObjStart()
|
|
s.encodeFields(e)
|
|
e.ObjEnd()
|
|
}
|
|
|
|
// encodeFields encodes fields.
|
|
func (s *GetSubscriptionsOK) encodeFields(e *jx.Encoder) {
|
|
{
|
|
e.FieldStart("subscriptions")
|
|
e.ArrStart()
|
|
for _, elem := range s.Subscriptions {
|
|
elem.Encode(e)
|
|
}
|
|
e.ArrEnd()
|
|
}
|
|
}
|
|
|
|
var jsonFieldsNameOfGetSubscriptionsOK = [1]string{
|
|
0: "subscriptions",
|
|
}
|
|
|
|
// Decode decodes GetSubscriptionsOK from json.
|
|
func (s *GetSubscriptionsOK) Decode(d *jx.Decoder) error {
|
|
if s == nil {
|
|
return errors.New("invalid: unable to decode GetSubscriptionsOK to nil")
|
|
}
|
|
var requiredBitSet [1]uint8
|
|
|
|
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
|
switch string(k) {
|
|
case "subscriptions":
|
|
requiredBitSet[0] |= 1 << 0
|
|
if err := func() error {
|
|
s.Subscriptions = make([]GetSubscriptionsOKSubscriptionsItem, 0)
|
|
if err := d.Arr(func(d *jx.Decoder) error {
|
|
var elem GetSubscriptionsOKSubscriptionsItem
|
|
if err := elem.Decode(d); err != nil {
|
|
return err
|
|
}
|
|
s.Subscriptions = append(s.Subscriptions, elem)
|
|
return nil
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return errors.Wrap(err, "decode field \"subscriptions\"")
|
|
}
|
|
default:
|
|
return d.Skip()
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return errors.Wrap(err, "decode GetSubscriptionsOK")
|
|
}
|
|
// Validate required fields.
|
|
var failures []validate.FieldError
|
|
for i, mask := range [1]uint8{
|
|
0b00000001,
|
|
} {
|
|
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
|
// Mask only required fields and check equality to mask using XOR.
|
|
//
|
|
// If XOR result is not zero, result is not equal to expected, so some fields are missed.
|
|
// Bits of fields which would be set are actually bits of missed fields.
|
|
missed := bits.OnesCount8(result)
|
|
for bitN := 0; bitN < missed; bitN++ {
|
|
bitIdx := bits.TrailingZeros8(result)
|
|
fieldIdx := i*8 + bitIdx
|
|
var name string
|
|
if fieldIdx < len(jsonFieldsNameOfGetSubscriptionsOK) {
|
|
name = jsonFieldsNameOfGetSubscriptionsOK[fieldIdx]
|
|
} else {
|
|
name = strconv.Itoa(fieldIdx)
|
|
}
|
|
failures = append(failures, validate.FieldError{
|
|
Name: name,
|
|
Error: validate.ErrFieldRequired,
|
|
})
|
|
// Reset bit.
|
|
result &^= 1 << bitIdx
|
|
}
|
|
}
|
|
}
|
|
if len(failures) > 0 {
|
|
return &validate.Error{Fields: failures}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalJSON implements stdjson.Marshaler.
|
|
func (s *GetSubscriptionsOK) MarshalJSON() ([]byte, error) {
|
|
e := jx.Encoder{}
|
|
s.Encode(&e)
|
|
return e.Bytes(), nil
|
|
}
|
|
|
|
// UnmarshalJSON implements stdjson.Unmarshaler.
|
|
func (s *GetSubscriptionsOK) UnmarshalJSON(data []byte) error {
|
|
d := jx.DecodeBytes(data)
|
|
return s.Decode(d)
|
|
}
|
|
|
|
// Encode implements json.Marshaler.
|
|
func (s *GetSubscriptionsOKSubscriptionsItem) Encode(e *jx.Encoder) {
|
|
e.ObjStart()
|
|
s.encodeFields(e)
|
|
e.ObjEnd()
|
|
}
|
|
|
|
// encodeFields encodes fields.
|
|
func (s *GetSubscriptionsOKSubscriptionsItem) encodeFields(e *jx.Encoder) {
|
|
{
|
|
e.FieldStart("id")
|
|
json.EncodeUUID(e, s.ID)
|
|
}
|
|
{
|
|
e.FieldStart("type")
|
|
s.Type.Encode(e)
|
|
}
|
|
{
|
|
e.FieldStart("status")
|
|
s.Status.Encode(e)
|
|
}
|
|
{
|
|
e.FieldStart("created_at")
|
|
json.EncodeDateTime(e, s.CreatedAt)
|
|
}
|
|
}
|
|
|
|
var jsonFieldsNameOfGetSubscriptionsOKSubscriptionsItem = [4]string{
|
|
0: "id",
|
|
1: "type",
|
|
2: "status",
|
|
3: "created_at",
|
|
}
|
|
|
|
// Decode decodes GetSubscriptionsOKSubscriptionsItem from json.
|
|
func (s *GetSubscriptionsOKSubscriptionsItem) Decode(d *jx.Decoder) error {
|
|
if s == nil {
|
|
return errors.New("invalid: unable to decode GetSubscriptionsOKSubscriptionsItem to nil")
|
|
}
|
|
var requiredBitSet [1]uint8
|
|
|
|
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
|
switch string(k) {
|
|
case "id":
|
|
requiredBitSet[0] |= 1 << 0
|
|
if err := func() error {
|
|
v, err := json.DecodeUUID(d)
|
|
s.ID = v
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return errors.Wrap(err, "decode field \"id\"")
|
|
}
|
|
case "type":
|
|
requiredBitSet[0] |= 1 << 1
|
|
if err := func() error {
|
|
if err := s.Type.Decode(d); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return errors.Wrap(err, "decode field \"type\"")
|
|
}
|
|
case "status":
|
|
requiredBitSet[0] |= 1 << 2
|
|
if err := func() error {
|
|
if err := s.Status.Decode(d); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return errors.Wrap(err, "decode field \"status\"")
|
|
}
|
|
case "created_at":
|
|
requiredBitSet[0] |= 1 << 3
|
|
if err := func() error {
|
|
v, err := json.DecodeDateTime(d)
|
|
s.CreatedAt = v
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return errors.Wrap(err, "decode field \"created_at\"")
|
|
}
|
|
default:
|
|
return d.Skip()
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return errors.Wrap(err, "decode GetSubscriptionsOKSubscriptionsItem")
|
|
}
|
|
// Validate required fields.
|
|
var failures []validate.FieldError
|
|
for i, mask := range [1]uint8{
|
|
0b00001111,
|
|
} {
|
|
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
|
// Mask only required fields and check equality to mask using XOR.
|
|
//
|
|
// If XOR result is not zero, result is not equal to expected, so some fields are missed.
|
|
// Bits of fields which would be set are actually bits of missed fields.
|
|
missed := bits.OnesCount8(result)
|
|
for bitN := 0; bitN < missed; bitN++ {
|
|
bitIdx := bits.TrailingZeros8(result)
|
|
fieldIdx := i*8 + bitIdx
|
|
var name string
|
|
if fieldIdx < len(jsonFieldsNameOfGetSubscriptionsOKSubscriptionsItem) {
|
|
name = jsonFieldsNameOfGetSubscriptionsOKSubscriptionsItem[fieldIdx]
|
|
} else {
|
|
name = strconv.Itoa(fieldIdx)
|
|
}
|
|
failures = append(failures, validate.FieldError{
|
|
Name: name,
|
|
Error: validate.ErrFieldRequired,
|
|
})
|
|
// Reset bit.
|
|
result &^= 1 << bitIdx
|
|
}
|
|
}
|
|
}
|
|
if len(failures) > 0 {
|
|
return &validate.Error{Fields: failures}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalJSON implements stdjson.Marshaler.
|
|
func (s *GetSubscriptionsOKSubscriptionsItem) MarshalJSON() ([]byte, error) {
|
|
e := jx.Encoder{}
|
|
s.Encode(&e)
|
|
return e.Bytes(), nil
|
|
}
|
|
|
|
// UnmarshalJSON implements stdjson.Unmarshaler.
|
|
func (s *GetSubscriptionsOKSubscriptionsItem) UnmarshalJSON(data []byte) error {
|
|
d := jx.DecodeBytes(data)
|
|
return s.Decode(d)
|
|
}
|
|
|
|
// Encode encodes GetSubscriptionsOKSubscriptionsItemStatus as json.
|
|
func (s GetSubscriptionsOKSubscriptionsItemStatus) Encode(e *jx.Encoder) {
|
|
e.Str(string(s))
|
|
}
|
|
|
|
// Decode decodes GetSubscriptionsOKSubscriptionsItemStatus from json.
|
|
func (s *GetSubscriptionsOKSubscriptionsItemStatus) Decode(d *jx.Decoder) error {
|
|
if s == nil {
|
|
return errors.New("invalid: unable to decode GetSubscriptionsOKSubscriptionsItemStatus to nil")
|
|
}
|
|
v, err := d.StrBytes()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Try to use constant string.
|
|
switch GetSubscriptionsOKSubscriptionsItemStatus(v) {
|
|
case GetSubscriptionsOKSubscriptionsItemStatusActive:
|
|
*s = GetSubscriptionsOKSubscriptionsItemStatusActive
|
|
case GetSubscriptionsOKSubscriptionsItemStatusOffline:
|
|
*s = GetSubscriptionsOKSubscriptionsItemStatusOffline
|
|
case GetSubscriptionsOKSubscriptionsItemStatusBusy:
|
|
*s = GetSubscriptionsOKSubscriptionsItemStatusBusy
|
|
default:
|
|
*s = GetSubscriptionsOKSubscriptionsItemStatus(v)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalJSON implements stdjson.Marshaler.
|
|
func (s GetSubscriptionsOKSubscriptionsItemStatus) MarshalJSON() ([]byte, error) {
|
|
e := jx.Encoder{}
|
|
s.Encode(&e)
|
|
return e.Bytes(), nil
|
|
}
|
|
|
|
// UnmarshalJSON implements stdjson.Unmarshaler.
|
|
func (s *GetSubscriptionsOKSubscriptionsItemStatus) UnmarshalJSON(data []byte) error {
|
|
d := jx.DecodeBytes(data)
|
|
return s.Decode(d)
|
|
}
|
|
|
|
// Encode encodes GetSubscriptionsOKSubscriptionsItemType as json.
|
|
func (s GetSubscriptionsOKSubscriptionsItemType) Encode(e *jx.Encoder) {
|
|
e.Str(string(s))
|
|
}
|
|
|
|
// Decode decodes GetSubscriptionsOKSubscriptionsItemType from json.
|
|
func (s *GetSubscriptionsOKSubscriptionsItemType) Decode(d *jx.Decoder) error {
|
|
if s == nil {
|
|
return errors.New("invalid: unable to decode GetSubscriptionsOKSubscriptionsItemType to nil")
|
|
}
|
|
v, err := d.StrBytes()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
// Try to use constant string.
|
|
switch GetSubscriptionsOKSubscriptionsItemType(v) {
|
|
case GetSubscriptionsOKSubscriptionsItemTypeStation:
|
|
*s = GetSubscriptionsOKSubscriptionsItemTypeStation
|
|
case GetSubscriptionsOKSubscriptionsItemTypeSatellite:
|
|
*s = GetSubscriptionsOKSubscriptionsItemTypeSatellite
|
|
default:
|
|
*s = GetSubscriptionsOKSubscriptionsItemType(v)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalJSON implements stdjson.Marshaler.
|
|
func (s GetSubscriptionsOKSubscriptionsItemType) MarshalJSON() ([]byte, error) {
|
|
e := jx.Encoder{}
|
|
s.Encode(&e)
|
|
return e.Bytes(), nil
|
|
}
|
|
|
|
// UnmarshalJSON implements stdjson.Unmarshaler.
|
|
func (s *GetSubscriptionsOKSubscriptionsItemType) UnmarshalJSON(data []byte) error {
|
|
d := jx.DecodeBytes(data)
|
|
return s.Decode(d)
|
|
}
|
|
|
|
// Encode encodes string as json.
|
|
func (o OptString) Encode(e *jx.Encoder) {
|
|
if !o.Set {
|
|
return
|
|
}
|
|
e.Str(string(o.Value))
|
|
}
|
|
|
|
// Decode decodes string from json.
|
|
func (o *OptString) Decode(d *jx.Decoder) error {
|
|
if o == nil {
|
|
return errors.New("invalid: unable to decode OptString to nil")
|
|
}
|
|
o.Set = true
|
|
v, err := d.Str()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
o.Value = string(v)
|
|
return nil
|
|
}
|
|
|
|
// MarshalJSON implements stdjson.Marshaler.
|
|
func (s OptString) MarshalJSON() ([]byte, error) {
|
|
e := jx.Encoder{}
|
|
s.Encode(&e)
|
|
return e.Bytes(), nil
|
|
}
|
|
|
|
// UnmarshalJSON implements stdjson.Unmarshaler.
|
|
func (s *OptString) UnmarshalJSON(data []byte) error {
|
|
d := jx.DecodeBytes(data)
|
|
return s.Decode(d)
|
|
}
|
|
|
|
// Encode implements json.Marshaler.
|
|
func (s *SubscribeSatelliteOK) Encode(e *jx.Encoder) {
|
|
e.ObjStart()
|
|
s.encodeFields(e)
|
|
e.ObjEnd()
|
|
}
|
|
|
|
// encodeFields encodes fields.
|
|
func (s *SubscribeSatelliteOK) encodeFields(e *jx.Encoder) {
|
|
{
|
|
e.FieldStart("id")
|
|
json.EncodeUUID(e, s.ID)
|
|
}
|
|
}
|
|
|
|
var jsonFieldsNameOfSubscribeSatelliteOK = [1]string{
|
|
0: "id",
|
|
}
|
|
|
|
// Decode decodes SubscribeSatelliteOK from json.
|
|
func (s *SubscribeSatelliteOK) Decode(d *jx.Decoder) error {
|
|
if s == nil {
|
|
return errors.New("invalid: unable to decode SubscribeSatelliteOK to nil")
|
|
}
|
|
var requiredBitSet [1]uint8
|
|
|
|
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
|
switch string(k) {
|
|
case "id":
|
|
requiredBitSet[0] |= 1 << 0
|
|
if err := func() error {
|
|
v, err := json.DecodeUUID(d)
|
|
s.ID = v
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return errors.Wrap(err, "decode field \"id\"")
|
|
}
|
|
default:
|
|
return d.Skip()
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return errors.Wrap(err, "decode SubscribeSatelliteOK")
|
|
}
|
|
// Validate required fields.
|
|
var failures []validate.FieldError
|
|
for i, mask := range [1]uint8{
|
|
0b00000001,
|
|
} {
|
|
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
|
// Mask only required fields and check equality to mask using XOR.
|
|
//
|
|
// If XOR result is not zero, result is not equal to expected, so some fields are missed.
|
|
// Bits of fields which would be set are actually bits of missed fields.
|
|
missed := bits.OnesCount8(result)
|
|
for bitN := 0; bitN < missed; bitN++ {
|
|
bitIdx := bits.TrailingZeros8(result)
|
|
fieldIdx := i*8 + bitIdx
|
|
var name string
|
|
if fieldIdx < len(jsonFieldsNameOfSubscribeSatelliteOK) {
|
|
name = jsonFieldsNameOfSubscribeSatelliteOK[fieldIdx]
|
|
} else {
|
|
name = strconv.Itoa(fieldIdx)
|
|
}
|
|
failures = append(failures, validate.FieldError{
|
|
Name: name,
|
|
Error: validate.ErrFieldRequired,
|
|
})
|
|
// Reset bit.
|
|
result &^= 1 << bitIdx
|
|
}
|
|
}
|
|
}
|
|
if len(failures) > 0 {
|
|
return &validate.Error{Fields: failures}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalJSON implements stdjson.Marshaler.
|
|
func (s *SubscribeSatelliteOK) MarshalJSON() ([]byte, error) {
|
|
e := jx.Encoder{}
|
|
s.Encode(&e)
|
|
return e.Bytes(), nil
|
|
}
|
|
|
|
// UnmarshalJSON implements stdjson.Unmarshaler.
|
|
func (s *SubscribeSatelliteOK) UnmarshalJSON(data []byte) error {
|
|
d := jx.DecodeBytes(data)
|
|
return s.Decode(d)
|
|
}
|
|
|
|
// Encode implements json.Marshaler.
|
|
func (s *SubscribeSatelliteReq) Encode(e *jx.Encoder) {
|
|
e.ObjStart()
|
|
s.encodeFields(e)
|
|
e.ObjEnd()
|
|
}
|
|
|
|
// encodeFields encodes fields.
|
|
func (s *SubscribeSatelliteReq) encodeFields(e *jx.Encoder) {
|
|
{
|
|
e.FieldStart("id")
|
|
json.EncodeUUID(e, s.ID)
|
|
}
|
|
}
|
|
|
|
var jsonFieldsNameOfSubscribeSatelliteReq = [1]string{
|
|
0: "id",
|
|
}
|
|
|
|
// Decode decodes SubscribeSatelliteReq from json.
|
|
func (s *SubscribeSatelliteReq) Decode(d *jx.Decoder) error {
|
|
if s == nil {
|
|
return errors.New("invalid: unable to decode SubscribeSatelliteReq to nil")
|
|
}
|
|
var requiredBitSet [1]uint8
|
|
|
|
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
|
switch string(k) {
|
|
case "id":
|
|
requiredBitSet[0] |= 1 << 0
|
|
if err := func() error {
|
|
v, err := json.DecodeUUID(d)
|
|
s.ID = v
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return errors.Wrap(err, "decode field \"id\"")
|
|
}
|
|
default:
|
|
return d.Skip()
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return errors.Wrap(err, "decode SubscribeSatelliteReq")
|
|
}
|
|
// Validate required fields.
|
|
var failures []validate.FieldError
|
|
for i, mask := range [1]uint8{
|
|
0b00000001,
|
|
} {
|
|
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
|
// Mask only required fields and check equality to mask using XOR.
|
|
//
|
|
// If XOR result is not zero, result is not equal to expected, so some fields are missed.
|
|
// Bits of fields which would be set are actually bits of missed fields.
|
|
missed := bits.OnesCount8(result)
|
|
for bitN := 0; bitN < missed; bitN++ {
|
|
bitIdx := bits.TrailingZeros8(result)
|
|
fieldIdx := i*8 + bitIdx
|
|
var name string
|
|
if fieldIdx < len(jsonFieldsNameOfSubscribeSatelliteReq) {
|
|
name = jsonFieldsNameOfSubscribeSatelliteReq[fieldIdx]
|
|
} else {
|
|
name = strconv.Itoa(fieldIdx)
|
|
}
|
|
failures = append(failures, validate.FieldError{
|
|
Name: name,
|
|
Error: validate.ErrFieldRequired,
|
|
})
|
|
// Reset bit.
|
|
result &^= 1 << bitIdx
|
|
}
|
|
}
|
|
}
|
|
if len(failures) > 0 {
|
|
return &validate.Error{Fields: failures}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalJSON implements stdjson.Marshaler.
|
|
func (s *SubscribeSatelliteReq) MarshalJSON() ([]byte, error) {
|
|
e := jx.Encoder{}
|
|
s.Encode(&e)
|
|
return e.Bytes(), nil
|
|
}
|
|
|
|
// UnmarshalJSON implements stdjson.Unmarshaler.
|
|
func (s *SubscribeSatelliteReq) UnmarshalJSON(data []byte) error {
|
|
d := jx.DecodeBytes(data)
|
|
return s.Decode(d)
|
|
}
|
|
|
|
// Encode implements json.Marshaler.
|
|
func (s *SubscribeStationOK) Encode(e *jx.Encoder) {
|
|
e.ObjStart()
|
|
s.encodeFields(e)
|
|
e.ObjEnd()
|
|
}
|
|
|
|
// encodeFields encodes fields.
|
|
func (s *SubscribeStationOK) encodeFields(e *jx.Encoder) {
|
|
{
|
|
e.FieldStart("id")
|
|
json.EncodeUUID(e, s.ID)
|
|
}
|
|
}
|
|
|
|
var jsonFieldsNameOfSubscribeStationOK = [1]string{
|
|
0: "id",
|
|
}
|
|
|
|
// Decode decodes SubscribeStationOK from json.
|
|
func (s *SubscribeStationOK) Decode(d *jx.Decoder) error {
|
|
if s == nil {
|
|
return errors.New("invalid: unable to decode SubscribeStationOK to nil")
|
|
}
|
|
var requiredBitSet [1]uint8
|
|
|
|
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
|
switch string(k) {
|
|
case "id":
|
|
requiredBitSet[0] |= 1 << 0
|
|
if err := func() error {
|
|
v, err := json.DecodeUUID(d)
|
|
s.ID = v
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return errors.Wrap(err, "decode field \"id\"")
|
|
}
|
|
default:
|
|
return d.Skip()
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return errors.Wrap(err, "decode SubscribeStationOK")
|
|
}
|
|
// Validate required fields.
|
|
var failures []validate.FieldError
|
|
for i, mask := range [1]uint8{
|
|
0b00000001,
|
|
} {
|
|
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
|
// Mask only required fields and check equality to mask using XOR.
|
|
//
|
|
// If XOR result is not zero, result is not equal to expected, so some fields are missed.
|
|
// Bits of fields which would be set are actually bits of missed fields.
|
|
missed := bits.OnesCount8(result)
|
|
for bitN := 0; bitN < missed; bitN++ {
|
|
bitIdx := bits.TrailingZeros8(result)
|
|
fieldIdx := i*8 + bitIdx
|
|
var name string
|
|
if fieldIdx < len(jsonFieldsNameOfSubscribeStationOK) {
|
|
name = jsonFieldsNameOfSubscribeStationOK[fieldIdx]
|
|
} else {
|
|
name = strconv.Itoa(fieldIdx)
|
|
}
|
|
failures = append(failures, validate.FieldError{
|
|
Name: name,
|
|
Error: validate.ErrFieldRequired,
|
|
})
|
|
// Reset bit.
|
|
result &^= 1 << bitIdx
|
|
}
|
|
}
|
|
}
|
|
if len(failures) > 0 {
|
|
return &validate.Error{Fields: failures}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalJSON implements stdjson.Marshaler.
|
|
func (s *SubscribeStationOK) MarshalJSON() ([]byte, error) {
|
|
e := jx.Encoder{}
|
|
s.Encode(&e)
|
|
return e.Bytes(), nil
|
|
}
|
|
|
|
// UnmarshalJSON implements stdjson.Unmarshaler.
|
|
func (s *SubscribeStationOK) UnmarshalJSON(data []byte) error {
|
|
d := jx.DecodeBytes(data)
|
|
return s.Decode(d)
|
|
}
|
|
|
|
// Encode implements json.Marshaler.
|
|
func (s *SubscribeStationReq) Encode(e *jx.Encoder) {
|
|
e.ObjStart()
|
|
s.encodeFields(e)
|
|
e.ObjEnd()
|
|
}
|
|
|
|
// encodeFields encodes fields.
|
|
func (s *SubscribeStationReq) encodeFields(e *jx.Encoder) {
|
|
{
|
|
e.FieldStart("id")
|
|
json.EncodeUUID(e, s.ID)
|
|
}
|
|
}
|
|
|
|
var jsonFieldsNameOfSubscribeStationReq = [1]string{
|
|
0: "id",
|
|
}
|
|
|
|
// Decode decodes SubscribeStationReq from json.
|
|
func (s *SubscribeStationReq) Decode(d *jx.Decoder) error {
|
|
if s == nil {
|
|
return errors.New("invalid: unable to decode SubscribeStationReq to nil")
|
|
}
|
|
var requiredBitSet [1]uint8
|
|
|
|
if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error {
|
|
switch string(k) {
|
|
case "id":
|
|
requiredBitSet[0] |= 1 << 0
|
|
if err := func() error {
|
|
v, err := json.DecodeUUID(d)
|
|
s.ID = v
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}(); err != nil {
|
|
return errors.Wrap(err, "decode field \"id\"")
|
|
}
|
|
default:
|
|
return d.Skip()
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return errors.Wrap(err, "decode SubscribeStationReq")
|
|
}
|
|
// Validate required fields.
|
|
var failures []validate.FieldError
|
|
for i, mask := range [1]uint8{
|
|
0b00000001,
|
|
} {
|
|
if result := (requiredBitSet[i] & mask) ^ mask; result != 0 {
|
|
// Mask only required fields and check equality to mask using XOR.
|
|
//
|
|
// If XOR result is not zero, result is not equal to expected, so some fields are missed.
|
|
// Bits of fields which would be set are actually bits of missed fields.
|
|
missed := bits.OnesCount8(result)
|
|
for bitN := 0; bitN < missed; bitN++ {
|
|
bitIdx := bits.TrailingZeros8(result)
|
|
fieldIdx := i*8 + bitIdx
|
|
var name string
|
|
if fieldIdx < len(jsonFieldsNameOfSubscribeStationReq) {
|
|
name = jsonFieldsNameOfSubscribeStationReq[fieldIdx]
|
|
} else {
|
|
name = strconv.Itoa(fieldIdx)
|
|
}
|
|
failures = append(failures, validate.FieldError{
|
|
Name: name,
|
|
Error: validate.ErrFieldRequired,
|
|
})
|
|
// Reset bit.
|
|
result &^= 1 << bitIdx
|
|
}
|
|
}
|
|
}
|
|
if len(failures) > 0 {
|
|
return &validate.Error{Fields: failures}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// MarshalJSON implements stdjson.Marshaler.
|
|
func (s *SubscribeStationReq) MarshalJSON() ([]byte, error) {
|
|
e := jx.Encoder{}
|
|
s.Encode(&e)
|
|
return e.Bytes(), nil
|
|
}
|
|
|
|
// UnmarshalJSON implements stdjson.Unmarshaler.
|
|
func (s *SubscribeStationReq) UnmarshalJSON(data []byte) error {
|
|
d := jx.DecodeBytes(data)
|
|
return s.Decode(d)
|
|
}
|