// Code generated by protoc-gen-go-frostfs. DO NOT EDIT. package test import ( json "encoding/json" fmt "fmt" pool "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/pool" proto "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/proto" encoding "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/proto/encoding" easyproto "github.com/VictoriaMetrics/easyproto" jlexer "github.com/mailru/easyjson/jlexer" jwriter "github.com/mailru/easyjson/jwriter" protowire "google.golang.org/protobuf/encoding/protowire" strconv "strconv" ) type Primitives_SomeEnum int32 const ( Primitives_UNKNOWN Primitives_SomeEnum = 0 Primitives_POSITIVE Primitives_SomeEnum = 1 Primitives_NEGATIVE Primitives_SomeEnum = -1 ) var ( Primitives_SomeEnum_name = map[int32]string{ 0: "UNKNOWN", 1: "POSITIVE", -1: "NEGATIVE", } Primitives_SomeEnum_value = map[string]int32{ "UNKNOWN": 0, "POSITIVE": 1, "NEGATIVE": -1, } ) func (x Primitives_SomeEnum) String() string { if v, ok := Primitives_SomeEnum_name[int32(x)]; ok { return v } return strconv.FormatInt(int64(x), 10) } func (x *Primitives_SomeEnum) FromString(s string) bool { if v, ok := Primitives_SomeEnum_value[s]; ok { *x = Primitives_SomeEnum(v) return true } return false } type Primitives struct { FieldA []byte `json:"fieldA"` FieldB string `json:"fieldB"` FieldC bool `json:"fieldC"` FieldD int32 `json:"fieldD"` FieldE uint32 `json:"fieldE"` FieldF int64 `json:"fieldF"` FieldG uint64 `json:"fieldG"` FieldI uint64 `json:"fieldI"` FieldJ float64 `json:"fieldJ"` FieldK uint32 `json:"fieldK"` FieldH Primitives_SomeEnum `json:"fieldH"` } var ( _ encoding.ProtoMarshaler = (*Primitives)(nil) _ encoding.ProtoUnmarshaler = (*Primitives)(nil) _ json.Marshaler = (*Primitives)(nil) _ json.Unmarshaler = (*Primitives)(nil) ) // StableSize returns the size of x in protobuf format. // // Structures with the same field values have the same binary size. func (x *Primitives) StableSize() (size int) { if x == nil { return 0 } size += proto.BytesSize(1, x.FieldA) size += proto.StringSize(2, x.FieldB) size += proto.BoolSize(200, x.FieldC) size += proto.Int32Size(201, x.FieldD) size += proto.UInt32Size(202, x.FieldE) size += proto.Int64Size(203, x.FieldF) size += proto.UInt64Size(204, x.FieldG) size += proto.Fixed64Size(205, x.FieldI) size += proto.Float64Size(206, x.FieldJ) size += proto.Fixed32Size(207, x.FieldK) size += proto.EnumSize(300, int32(x.FieldH)) return size } // MarshalProtobuf implements the encoding.ProtoMarshaler interface. func (x *Primitives) MarshalProtobuf(dst []byte) []byte { m := pool.MarshalerPool.Get() defer pool.MarshalerPool.Put(m) x.EmitProtobuf(m.MessageMarshaler()) dst = m.Marshal(dst) return dst } func (x *Primitives) EmitProtobuf(mm *easyproto.MessageMarshaler) { if x == nil { return } if len(x.FieldA) != 0 { mm.AppendBytes(1, x.FieldA) } if len(x.FieldB) != 0 { mm.AppendString(2, x.FieldB) } if x.FieldC { mm.AppendBool(200, x.FieldC) } if x.FieldD != 0 { mm.AppendInt32(201, x.FieldD) } if x.FieldE != 0 { mm.AppendUint32(202, x.FieldE) } if x.FieldF != 0 { mm.AppendInt64(203, x.FieldF) } if x.FieldG != 0 { mm.AppendUint64(204, x.FieldG) } if x.FieldI != 0 { mm.AppendFixed64(205, x.FieldI) } if x.FieldJ != 0 { mm.AppendDouble(206, x.FieldJ) } if x.FieldK != 0 { mm.AppendFixed32(207, x.FieldK) } if int32(x.FieldH) != 0 { mm.AppendInt32(300, int32(x.FieldH)) } } // UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. func (x *Primitives) UnmarshalProtobuf(src []byte) (err error) { var fc easyproto.FieldContext for len(src) > 0 { src, err = fc.NextField(src) if err != nil { return fmt.Errorf("cannot read next field in %s", "Primitives") } switch fc.FieldNum { case 1: // FieldA data, ok := fc.Bytes() if !ok { return fmt.Errorf("cannot unmarshal field %s", "FieldA") } x.FieldA = data case 2: // FieldB data, ok := fc.String() if !ok { return fmt.Errorf("cannot unmarshal field %s", "FieldB") } x.FieldB = data case 200: // FieldC data, ok := fc.Bool() if !ok { return fmt.Errorf("cannot unmarshal field %s", "FieldC") } x.FieldC = data case 201: // FieldD data, ok := fc.Int32() if !ok { return fmt.Errorf("cannot unmarshal field %s", "FieldD") } x.FieldD = data case 202: // FieldE data, ok := fc.Uint32() if !ok { return fmt.Errorf("cannot unmarshal field %s", "FieldE") } x.FieldE = data case 203: // FieldF data, ok := fc.Int64() if !ok { return fmt.Errorf("cannot unmarshal field %s", "FieldF") } x.FieldF = data case 204: // FieldG data, ok := fc.Uint64() if !ok { return fmt.Errorf("cannot unmarshal field %s", "FieldG") } x.FieldG = data case 205: // FieldI data, ok := fc.Fixed64() if !ok { return fmt.Errorf("cannot unmarshal field %s", "FieldI") } x.FieldI = data case 206: // FieldJ data, ok := fc.Double() if !ok { return fmt.Errorf("cannot unmarshal field %s", "FieldJ") } x.FieldJ = data case 207: // FieldK data, ok := fc.Fixed32() if !ok { return fmt.Errorf("cannot unmarshal field %s", "FieldK") } x.FieldK = data case 300: // FieldH data, ok := fc.Int32() if !ok { return fmt.Errorf("cannot unmarshal field %s", "FieldH") } x.FieldH = Primitives_SomeEnum(data) } } return nil } func (x *Primitives) GetFieldA() []byte { if x != nil { return x.FieldA } return nil } func (x *Primitives) SetFieldA(v []byte) { x.FieldA = v } func (x *Primitives) GetFieldB() string { if x != nil { return x.FieldB } return "" } func (x *Primitives) SetFieldB(v string) { x.FieldB = v } func (x *Primitives) GetFieldC() bool { if x != nil { return x.FieldC } return false } func (x *Primitives) SetFieldC(v bool) { x.FieldC = v } func (x *Primitives) GetFieldD() int32 { if x != nil { return x.FieldD } return 0 } func (x *Primitives) SetFieldD(v int32) { x.FieldD = v } func (x *Primitives) GetFieldE() uint32 { if x != nil { return x.FieldE } return 0 } func (x *Primitives) SetFieldE(v uint32) { x.FieldE = v } func (x *Primitives) GetFieldF() int64 { if x != nil { return x.FieldF } return 0 } func (x *Primitives) SetFieldF(v int64) { x.FieldF = v } func (x *Primitives) GetFieldG() uint64 { if x != nil { return x.FieldG } return 0 } func (x *Primitives) SetFieldG(v uint64) { x.FieldG = v } func (x *Primitives) GetFieldI() uint64 { if x != nil { return x.FieldI } return 0 } func (x *Primitives) SetFieldI(v uint64) { x.FieldI = v } func (x *Primitives) GetFieldJ() float64 { if x != nil { return x.FieldJ } return 0 } func (x *Primitives) SetFieldJ(v float64) { x.FieldJ = v } func (x *Primitives) GetFieldK() uint32 { if x != nil { return x.FieldK } return 0 } func (x *Primitives) SetFieldK(v uint32) { x.FieldK = v } func (x *Primitives) GetFieldH() Primitives_SomeEnum { if x != nil { return x.FieldH } return 0 } func (x *Primitives) SetFieldH(v Primitives_SomeEnum) { x.FieldH = v } // MarshalJSON implements the json.Marshaler interface. func (x *Primitives) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} x.MarshalEasyJSON(&w) return w.Buffer.BuildBytes(), w.Error } func (x *Primitives) MarshalEasyJSON(out *jwriter.Writer) { if x == nil { out.RawString("null") return } out.RawByte('{') { const prefix string = ",\"fieldA\":" out.RawString(prefix[1:]) out.Base64Bytes(x.FieldA) } { const prefix string = ",\"fieldB\":" out.RawString(prefix) out.String(x.FieldB) } { const prefix string = ",\"fieldC\":" out.RawString(prefix) out.Bool(x.FieldC) } { const prefix string = ",\"fieldD\":" out.RawString(prefix) out.Int32(x.FieldD) } { const prefix string = ",\"fieldE\":" out.RawString(prefix) out.Uint32(x.FieldE) } { const prefix string = ",\"fieldF\":" out.RawString(prefix) out.Int64(x.FieldF) } { const prefix string = ",\"fieldG\":" out.RawString(prefix) out.Uint64(x.FieldG) } { const prefix string = ",\"fieldI\":" out.RawString(prefix) out.Uint64(x.FieldI) } { const prefix string = ",\"fieldJ\":" out.RawString(prefix) out.Float64(x.FieldJ) } { const prefix string = ",\"fieldK\":" out.RawString(prefix) out.Uint32(x.FieldK) } { const prefix string = ",\"fieldH\":" out.RawString(prefix) out.Int32(int32(x.FieldH)) } out.RawByte('}') } // UnmarshalJSON implements the json.Unmarshaler interface. func (x *Primitives) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} x.UnmarshalEasyJSON(&r) return r.Error() } func (x *Primitives) UnmarshalEasyJSON(in *jlexer.Lexer) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { in.Consumed() } in.Skip() return } in.Delim('{') for !in.IsDelim('}') { key := in.UnsafeFieldName(false) in.WantColon() if in.IsNull() { in.Skip() in.WantComma() continue } switch key { case "fieldA": { var f []byte f = in.Bytes() x.FieldA = f } case "fieldB": { var f string f = in.String() x.FieldB = f } case "fieldC": { var f bool f = in.Bool() x.FieldC = f } case "fieldD": { var f int32 f = in.Int32() x.FieldD = f } case "fieldE": { var f uint32 f = in.Uint32() x.FieldE = f } case "fieldF": { var f int64 f = in.Int64() x.FieldF = f } case "fieldG": { var f uint64 f = in.Uint64() x.FieldG = f } case "fieldI": { var f uint64 f = in.Uint64() x.FieldI = f } case "fieldJ": { var f float64 f = in.Float64() x.FieldJ = f } case "fieldK": { var f uint32 f = in.Uint32() x.FieldK = f } case "fieldH": { var f Primitives_SomeEnum var parsedValue Primitives_SomeEnum switch v := in.Interface().(type) { case string: if vv, ok := Primitives_SomeEnum_value[v]; ok { parsedValue = Primitives_SomeEnum(vv) break } vv, err := strconv.ParseInt(v, 10, 32) if err != nil { in.AddError(err) return } parsedValue = Primitives_SomeEnum(vv) case float64: parsedValue = Primitives_SomeEnum(v) } f = parsedValue x.FieldH = f } } in.WantComma() } in.Delim('}') if isTopLevel { in.Consumed() } } type RepPrimitives struct { FieldA [][]byte `json:"fieldA"` FieldB []string `json:"fieldB"` FieldC []int32 `json:"fieldC"` FieldD []uint32 `json:"fieldD"` FieldE []int64 `json:"fieldE"` FieldF []uint64 `json:"fieldF"` FieldFu []uint64 `json:"fieldFu"` } var ( _ encoding.ProtoMarshaler = (*RepPrimitives)(nil) _ encoding.ProtoUnmarshaler = (*RepPrimitives)(nil) _ json.Marshaler = (*RepPrimitives)(nil) _ json.Unmarshaler = (*RepPrimitives)(nil) ) // StableSize returns the size of x in protobuf format. // // Structures with the same field values have the same binary size. func (x *RepPrimitives) StableSize() (size int) { if x == nil { return 0 } var n int size += proto.RepeatedBytesSize(1, x.FieldA) size += proto.RepeatedStringSize(2, x.FieldB) n, _ = proto.RepeatedInt32Size(3, x.FieldC) size += n n, _ = proto.RepeatedUInt32Size(4, x.FieldD) size += n n, _ = proto.RepeatedInt64Size(5, x.FieldE) size += n n, _ = proto.RepeatedUInt64Size(6, x.FieldF) size += n for i := range x.FieldFu { size += protowire.SizeGroup(protowire.Number(7), protowire.SizeVarint(x.FieldFu[i])) } return size } // MarshalProtobuf implements the encoding.ProtoMarshaler interface. func (x *RepPrimitives) MarshalProtobuf(dst []byte) []byte { m := pool.MarshalerPool.Get() defer pool.MarshalerPool.Put(m) x.EmitProtobuf(m.MessageMarshaler()) dst = m.Marshal(dst) return dst } func (x *RepPrimitives) EmitProtobuf(mm *easyproto.MessageMarshaler) { if x == nil { return } for j := range x.FieldA { mm.AppendBytes(1, x.FieldA[j]) } for j := range x.FieldB { mm.AppendString(2, x.FieldB[j]) } if len(x.FieldC) != 0 { mm.AppendInt32s(3, x.FieldC) } if len(x.FieldD) != 0 { mm.AppendUint32s(4, x.FieldD) } if len(x.FieldE) != 0 { mm.AppendInt64s(5, x.FieldE) } if len(x.FieldF) != 0 { mm.AppendUint64s(6, x.FieldF) } for j := range x.FieldFu { mm.AppendUint64(7, x.FieldFu[j]) } } // UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface. func (x *RepPrimitives) UnmarshalProtobuf(src []byte) (err error) { var fc easyproto.FieldContext for len(src) > 0 { src, err = fc.NextField(src) if err != nil { return fmt.Errorf("cannot read next field in %s", "RepPrimitives") } switch fc.FieldNum { case 1: // FieldA data, ok := fc.Bytes() if !ok { return fmt.Errorf("cannot unmarshal field %s", "FieldA") } x.FieldA = append(x.FieldA, data) case 2: // FieldB data, ok := fc.String() if !ok { return fmt.Errorf("cannot unmarshal field %s", "FieldB") } x.FieldB = append(x.FieldB, data) case 3: // FieldC data, ok := fc.UnpackInt32s(nil) if !ok { return fmt.Errorf("cannot unmarshal field %s", "FieldC") } x.FieldC = data case 4: // FieldD data, ok := fc.UnpackUint32s(nil) if !ok { return fmt.Errorf("cannot unmarshal field %s", "FieldD") } x.FieldD = data case 5: // FieldE data, ok := fc.UnpackInt64s(nil) if !ok { return fmt.Errorf("cannot unmarshal field %s", "FieldE") } x.FieldE = data case 6: // FieldF data, ok := fc.UnpackUint64s(nil) if !ok { return fmt.Errorf("cannot unmarshal field %s", "FieldF") } x.FieldF = data case 7: // FieldFu data, ok := fc.Uint64() if !ok { return fmt.Errorf("cannot unmarshal field %s", "FieldFu") } x.FieldFu = append(x.FieldFu, data) } } return nil } func (x *RepPrimitives) GetFieldA() [][]byte { if x != nil { return x.FieldA } return nil } func (x *RepPrimitives) SetFieldA(v [][]byte) { x.FieldA = v } func (x *RepPrimitives) GetFieldB() []string { if x != nil { return x.FieldB } return nil } func (x *RepPrimitives) SetFieldB(v []string) { x.FieldB = v } func (x *RepPrimitives) GetFieldC() []int32 { if x != nil { return x.FieldC } return nil } func (x *RepPrimitives) SetFieldC(v []int32) { x.FieldC = v } func (x *RepPrimitives) GetFieldD() []uint32 { if x != nil { return x.FieldD } return nil } func (x *RepPrimitives) SetFieldD(v []uint32) { x.FieldD = v } func (x *RepPrimitives) GetFieldE() []int64 { if x != nil { return x.FieldE } return nil } func (x *RepPrimitives) SetFieldE(v []int64) { x.FieldE = v } func (x *RepPrimitives) GetFieldF() []uint64 { if x != nil { return x.FieldF } return nil } func (x *RepPrimitives) SetFieldF(v []uint64) { x.FieldF = v } func (x *RepPrimitives) GetFieldFu() []uint64 { if x != nil { return x.FieldFu } return nil } func (x *RepPrimitives) SetFieldFu(v []uint64) { x.FieldFu = v } // MarshalJSON implements the json.Marshaler interface. func (x *RepPrimitives) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} x.MarshalEasyJSON(&w) return w.Buffer.BuildBytes(), w.Error } func (x *RepPrimitives) MarshalEasyJSON(out *jwriter.Writer) { if x == nil { out.RawString("null") return } out.RawByte('{') { const prefix string = ",\"fieldA\":" out.RawString(prefix[1:]) out.RawByte('[') for i := range x.FieldA { if i != 0 { out.RawByte(',') } out.Base64Bytes(x.FieldA[i]) } out.RawByte(']') } { const prefix string = ",\"fieldB\":" out.RawString(prefix) out.RawByte('[') for i := range x.FieldB { if i != 0 { out.RawByte(',') } out.String(x.FieldB[i]) } out.RawByte(']') } { const prefix string = ",\"fieldC\":" out.RawString(prefix) out.RawByte('[') for i := range x.FieldC { if i != 0 { out.RawByte(',') } out.Int32(x.FieldC[i]) } out.RawByte(']') } { const prefix string = ",\"fieldD\":" out.RawString(prefix) out.RawByte('[') for i := range x.FieldD { if i != 0 { out.RawByte(',') } out.Uint32(x.FieldD[i]) } out.RawByte(']') } { const prefix string = ",\"fieldE\":" out.RawString(prefix) out.RawByte('[') for i := range x.FieldE { if i != 0 { out.RawByte(',') } out.Int64(x.FieldE[i]) } out.RawByte(']') } { const prefix string = ",\"fieldF\":" out.RawString(prefix) out.RawByte('[') for i := range x.FieldF { if i != 0 { out.RawByte(',') } out.Uint64(x.FieldF[i]) } out.RawByte(']') } { const prefix string = ",\"fieldFu\":" out.RawString(prefix) out.RawByte('[') for i := range x.FieldFu { if i != 0 { out.RawByte(',') } out.Uint64(x.FieldFu[i]) } out.RawByte(']') } out.RawByte('}') } // UnmarshalJSON implements the json.Unmarshaler interface. func (x *RepPrimitives) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} x.UnmarshalEasyJSON(&r) return r.Error() } func (x *RepPrimitives) UnmarshalEasyJSON(in *jlexer.Lexer) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { in.Consumed() } in.Skip() return } in.Delim('{') for !in.IsDelim('}') { key := in.UnsafeFieldName(false) in.WantColon() if in.IsNull() { in.Skip() in.WantComma() continue } switch key { case "fieldA": { var f []byte var list [][]byte in.Delim('[') for !in.IsDelim(']') { f = in.Bytes() list = append(list, f) in.WantComma() } x.FieldA = list in.Delim(']') } case "fieldB": { var f string var list []string in.Delim('[') for !in.IsDelim(']') { f = in.String() list = append(list, f) in.WantComma() } x.FieldB = list in.Delim(']') } case "fieldC": { var f int32 var list []int32 in.Delim('[') for !in.IsDelim(']') { f = in.Int32() list = append(list, f) in.WantComma() } x.FieldC = list in.Delim(']') } case "fieldD": { var f uint32 var list []uint32 in.Delim('[') for !in.IsDelim(']') { f = in.Uint32() list = append(list, f) in.WantComma() } x.FieldD = list in.Delim(']') } case "fieldE": { var f int64 var list []int64 in.Delim('[') for !in.IsDelim(']') { f = in.Int64() list = append(list, f) in.WantComma() } x.FieldE = list in.Delim(']') } case "fieldF": { var f uint64 var list []uint64 in.Delim('[') for !in.IsDelim(']') { f = in.Uint64() list = append(list, f) in.WantComma() } x.FieldF = list in.Delim(']') } case "fieldFu": { var f uint64 var list []uint64 in.Delim('[') for !in.IsDelim(']') { f = in.Uint64() list = append(list, f) in.WantComma() } x.FieldFu = list in.Delim(']') } } in.WantComma() } in.Delim('}') if isTopLevel { in.Consumed() } }