frostfs-api-go/util/proto/test/custom/test_frostfs.pb.go
Evgenii Stratonikov b06dad731c [#120] protogen: Marshal 64-bit integers as strings
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2024-10-01 14:18:46 +03:00

1705 lines
35 KiB
Go
Generated

// 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_Aux struct {
InnerField uint32 `json:"innerField"`
}
var (
_ encoding.ProtoMarshaler = (*Primitives_Aux)(nil)
_ encoding.ProtoUnmarshaler = (*Primitives_Aux)(nil)
_ json.Marshaler = (*Primitives_Aux)(nil)
_ json.Unmarshaler = (*Primitives_Aux)(nil)
)
// StableSize returns the size of x in protobuf format.
//
// Structures with the same field values have the same binary size.
func (x *Primitives_Aux) StableSize() (size int) {
if x == nil {
return 0
}
size += proto.UInt32Size(1, x.InnerField)
return size
}
// MarshalProtobuf implements the encoding.ProtoMarshaler interface.
func (x *Primitives_Aux) 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_Aux) EmitProtobuf(mm *easyproto.MessageMarshaler) {
if x == nil {
return
}
if x.InnerField != 0 {
mm.AppendUint32(1, x.InnerField)
}
}
// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface.
func (x *Primitives_Aux) 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_Aux")
}
switch fc.FieldNum {
case 1: // InnerField
data, ok := fc.Uint32()
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "InnerField")
}
x.InnerField = data
}
}
return nil
}
func (x *Primitives_Aux) GetInnerField() uint32 {
if x != nil {
return x.InnerField
}
return 0
}
func (x *Primitives_Aux) SetInnerField(v uint32) {
x.InnerField = v
}
// MarshalJSON implements the json.Marshaler interface.
func (x *Primitives_Aux) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
x.MarshalEasyJSON(&w)
return w.Buffer.BuildBytes(), w.Error
}
func (x *Primitives_Aux) MarshalEasyJSON(out *jwriter.Writer) {
if x == nil {
out.RawString("null")
return
}
first := true
out.RawByte('{')
{
if x.InnerField != 0 {
if !first {
out.RawByte(',')
} else {
first = false
}
const prefix string = "\"innerField\":"
out.RawString(prefix)
out.Uint32(x.InnerField)
}
}
out.RawByte('}')
}
// UnmarshalJSON implements the json.Unmarshaler interface.
func (x *Primitives_Aux) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
x.UnmarshalEasyJSON(&r)
return r.Error()
}
func (x *Primitives_Aux) 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 "innerField":
{
var f uint32
r := in.JsonNumber()
n := r.String()
v, err := strconv.ParseUint(n, 10, 32)
if err != nil {
in.AddError(err)
return
}
pv := uint32(v)
f = pv
x.InnerField = f
}
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
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"`
FieldM isPrimitives_FieldM
}
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))
if inner, ok := x.FieldM.(*Primitives_FieldMa); ok {
size += proto.BytesSize(401, inner.FieldMa)
}
if inner, ok := x.FieldM.(*Primitives_FieldMe); ok {
size += proto.UInt32Size(402, inner.FieldMe)
}
if inner, ok := x.FieldM.(*Primitives_FieldAux); ok {
size += proto.NestedStructureSize(403, inner.FieldAux)
}
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))
}
if inner, ok := x.FieldM.(*Primitives_FieldMa); ok {
if len(inner.FieldMa) != 0 {
mm.AppendBytes(401, inner.FieldMa)
}
}
if inner, ok := x.FieldM.(*Primitives_FieldMe); ok {
if inner.FieldMe != 0 {
mm.AppendUint32(402, inner.FieldMe)
}
}
if inner, ok := x.FieldM.(*Primitives_FieldAux); ok {
if inner.FieldAux != nil {
inner.FieldAux.EmitProtobuf(mm.AppendMessage(403))
}
}
}
// 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)
case 401: // FieldMa
data, ok := fc.Bytes()
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "FieldMa")
}
x.FieldM = &Primitives_FieldMa{FieldMa: data}
case 402: // FieldMe
data, ok := fc.Uint32()
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "FieldMe")
}
x.FieldM = &Primitives_FieldMe{FieldMe: data}
case 403: // FieldAux
data, ok := fc.MessageData()
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "FieldAux")
}
oneofField := &Primitives_FieldAux{FieldAux: new(Primitives_Aux)}
if err := oneofField.FieldAux.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
x.FieldM = oneofField
}
}
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
}
func (x *Primitives) GetFieldM() isPrimitives_FieldM {
if x != nil {
return x.FieldM
}
return nil
}
func (x *Primitives) SetFieldM(v isPrimitives_FieldM) {
x.FieldM = v
}
func (x *Primitives) GetFieldMa() []byte {
if xx, ok := x.GetFieldM().(*Primitives_FieldMa); ok {
return xx.FieldMa
}
return nil
}
func (x *Primitives) SetFieldMa(v *Primitives_FieldMa) {
x.FieldM = v
}
func (x *Primitives_FieldMa) GetFieldMa() []byte {
if x != nil {
return x.FieldMa
}
return nil
}
func (x *Primitives_FieldMa) SetFieldMa(v []byte) {
x.FieldMa = v
}
func (x *Primitives) GetFieldMe() uint32 {
if xx, ok := x.GetFieldM().(*Primitives_FieldMe); ok {
return xx.FieldMe
}
return 0
}
func (x *Primitives) SetFieldMe(v *Primitives_FieldMe) {
x.FieldM = v
}
func (x *Primitives_FieldMe) GetFieldMe() uint32 {
if x != nil {
return x.FieldMe
}
return 0
}
func (x *Primitives_FieldMe) SetFieldMe(v uint32) {
x.FieldMe = v
}
func (x *Primitives) GetFieldAux() *Primitives_Aux {
if xx, ok := x.GetFieldM().(*Primitives_FieldAux); ok {
return xx.FieldAux
}
return nil
}
func (x *Primitives) SetFieldAux(v *Primitives_Aux) {
x.FieldM = &Primitives_FieldAux{FieldAux: 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
}
first := true
out.RawByte('{')
{
if len(x.FieldA) != 0 {
if !first {
out.RawByte(',')
} else {
first = false
}
const prefix string = "\"fieldA\":"
out.RawString(prefix)
out.Base64Bytes(x.FieldA)
}
}
{
if len(x.FieldB) != 0 {
if !first {
out.RawByte(',')
} else {
first = false
}
const prefix string = "\"fieldB\":"
out.RawString(prefix)
out.String(x.FieldB)
}
}
{
if x.FieldC {
if !first {
out.RawByte(',')
} else {
first = false
}
const prefix string = "\"fieldC\":"
out.RawString(prefix)
out.Bool(x.FieldC)
}
}
{
if x.FieldD != 0 {
if !first {
out.RawByte(',')
} else {
first = false
}
const prefix string = "\"fieldD\":"
out.RawString(prefix)
out.Int32(x.FieldD)
}
}
{
if x.FieldE != 0 {
if !first {
out.RawByte(',')
} else {
first = false
}
const prefix string = "\"fieldE\":"
out.RawString(prefix)
out.Uint32(x.FieldE)
}
}
{
if x.FieldF != 0 {
if !first {
out.RawByte(',')
} else {
first = false
}
const prefix string = "\"fieldF\":"
out.RawString(prefix)
out.RawByte('"')
out.Buffer.Buf = strconv.AppendInt(out.Buffer.Buf, x.FieldF, 10)
out.RawByte('"')
}
}
{
if x.FieldG != 0 {
if !first {
out.RawByte(',')
} else {
first = false
}
const prefix string = "\"fieldG\":"
out.RawString(prefix)
out.RawByte('"')
out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.FieldG, 10)
out.RawByte('"')
}
}
{
if x.FieldI != 0 {
if !first {
out.RawByte(',')
} else {
first = false
}
const prefix string = "\"fieldI\":"
out.RawString(prefix)
out.RawByte('"')
out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.FieldI, 10)
out.RawByte('"')
}
}
{
if x.FieldJ != 0 {
if !first {
out.RawByte(',')
} else {
first = false
}
const prefix string = "\"fieldJ\":"
out.RawString(prefix)
out.Float64(x.FieldJ)
}
}
{
if x.FieldK != 0 {
if !first {
out.RawByte(',')
} else {
first = false
}
const prefix string = "\"fieldK\":"
out.RawString(prefix)
out.Uint32(x.FieldK)
}
}
{
if x.FieldH != 0 {
if !first {
out.RawByte(',')
} else {
first = false
}
const prefix string = "\"fieldH\":"
out.RawString(prefix)
v := int32(x.FieldH)
if vv, ok := Primitives_SomeEnum_name[v]; ok {
out.String(vv)
} else {
out.Int32(v)
}
}
}
switch xx := x.FieldM.(type) {
case *Primitives_FieldMa:
{
if len(xx.FieldMa) != 0 {
if !first {
out.RawByte(',')
} else {
first = false
}
const prefix string = "\"fieldMa\":"
out.RawString(prefix)
out.Base64Bytes(xx.FieldMa)
}
}
case *Primitives_FieldMe:
{
if xx.FieldMe != 0 {
if !first {
out.RawByte(',')
} else {
first = false
}
const prefix string = "\"fieldMe\":"
out.RawString(prefix)
out.Uint32(xx.FieldMe)
}
}
case *Primitives_FieldAux:
{
if xx.FieldAux != nil {
if !first {
out.RawByte(',')
} else {
first = false
}
const prefix string = "\"fieldAux\":"
out.RawString(prefix)
xx.FieldAux.MarshalEasyJSON(out)
}
}
}
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
r := in.JsonNumber()
n := r.String()
v, err := strconv.ParseInt(n, 10, 32)
if err != nil {
in.AddError(err)
return
}
pv := int32(v)
f = pv
x.FieldD = f
}
case "fieldE":
{
var f uint32
r := in.JsonNumber()
n := r.String()
v, err := strconv.ParseUint(n, 10, 32)
if err != nil {
in.AddError(err)
return
}
pv := uint32(v)
f = pv
x.FieldE = f
}
case "fieldF":
{
var f int64
r := in.JsonNumber()
n := r.String()
v, err := strconv.ParseInt(n, 10, 64)
if err != nil {
in.AddError(err)
return
}
pv := int64(v)
f = pv
x.FieldF = f
}
case "fieldG":
{
var f uint64
r := in.JsonNumber()
n := r.String()
v, err := strconv.ParseUint(n, 10, 64)
if err != nil {
in.AddError(err)
return
}
pv := uint64(v)
f = pv
x.FieldG = f
}
case "fieldI":
{
var f uint64
r := in.JsonNumber()
n := r.String()
v, err := strconv.ParseUint(n, 10, 64)
if err != nil {
in.AddError(err)
return
}
pv := uint64(v)
f = pv
x.FieldI = f
}
case "fieldJ":
{
var f float64
f = in.Float64()
x.FieldJ = f
}
case "fieldK":
{
var f uint32
r := in.JsonNumber()
n := r.String()
v, err := strconv.ParseUint(n, 10, 32)
if err != nil {
in.AddError(err)
return
}
pv := uint32(v)
f = pv
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
}
case "fieldMa":
xx := new(Primitives_FieldMa)
x.FieldM = xx
{
var f []byte
f = in.Bytes()
xx.FieldMa = f
}
case "fieldMe":
xx := new(Primitives_FieldMe)
x.FieldM = xx
{
var f uint32
r := in.JsonNumber()
n := r.String()
v, err := strconv.ParseUint(n, 10, 32)
if err != nil {
in.AddError(err)
return
}
pv := uint32(v)
f = pv
xx.FieldMe = f
}
case "fieldAux":
xx := new(Primitives_FieldAux)
x.FieldM = xx
{
var f *Primitives_Aux
f = new(Primitives_Aux)
f.UnmarshalEasyJSON(in)
xx.FieldAux = f
}
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
type isPrimitives_FieldM interface {
isPrimitives_FieldM()
}
type Primitives_FieldMa struct {
FieldMa []byte
}
type Primitives_FieldMe struct {
FieldMe uint32
}
type Primitives_FieldAux struct {
FieldAux *Primitives_Aux
}
func (*Primitives_FieldMa) isPrimitives_FieldM() {}
func (*Primitives_FieldMe) isPrimitives_FieldM() {}
func (*Primitives_FieldAux) isPrimitives_FieldM() {}
type RepPrimitives_Aux struct {
InnerField uint32 `json:"innerField"`
}
var (
_ encoding.ProtoMarshaler = (*RepPrimitives_Aux)(nil)
_ encoding.ProtoUnmarshaler = (*RepPrimitives_Aux)(nil)
_ json.Marshaler = (*RepPrimitives_Aux)(nil)
_ json.Unmarshaler = (*RepPrimitives_Aux)(nil)
)
// StableSize returns the size of x in protobuf format.
//
// Structures with the same field values have the same binary size.
func (x *RepPrimitives_Aux) StableSize() (size int) {
if x == nil {
return 0
}
size += proto.UInt32Size(1, x.InnerField)
return size
}
// MarshalProtobuf implements the encoding.ProtoMarshaler interface.
func (x *RepPrimitives_Aux) 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_Aux) EmitProtobuf(mm *easyproto.MessageMarshaler) {
if x == nil {
return
}
if x.InnerField != 0 {
mm.AppendUint32(1, x.InnerField)
}
}
// UnmarshalProtobuf implements the encoding.ProtoUnmarshaler interface.
func (x *RepPrimitives_Aux) 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_Aux")
}
switch fc.FieldNum {
case 1: // InnerField
data, ok := fc.Uint32()
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "InnerField")
}
x.InnerField = data
}
}
return nil
}
func (x *RepPrimitives_Aux) GetInnerField() uint32 {
if x != nil {
return x.InnerField
}
return 0
}
func (x *RepPrimitives_Aux) SetInnerField(v uint32) {
x.InnerField = v
}
// MarshalJSON implements the json.Marshaler interface.
func (x *RepPrimitives_Aux) MarshalJSON() ([]byte, error) {
w := jwriter.Writer{}
x.MarshalEasyJSON(&w)
return w.Buffer.BuildBytes(), w.Error
}
func (x *RepPrimitives_Aux) MarshalEasyJSON(out *jwriter.Writer) {
if x == nil {
out.RawString("null")
return
}
first := true
out.RawByte('{')
{
if x.InnerField != 0 {
if !first {
out.RawByte(',')
} else {
first = false
}
const prefix string = "\"innerField\":"
out.RawString(prefix)
out.Uint32(x.InnerField)
}
}
out.RawByte('}')
}
// UnmarshalJSON implements the json.Unmarshaler interface.
func (x *RepPrimitives_Aux) UnmarshalJSON(data []byte) error {
r := jlexer.Lexer{Data: data}
x.UnmarshalEasyJSON(&r)
return r.Error()
}
func (x *RepPrimitives_Aux) 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 "innerField":
{
var f uint32
r := in.JsonNumber()
n := r.String()
v, err := strconv.ParseUint(n, 10, 32)
if err != nil {
in.AddError(err)
return
}
pv := uint32(v)
f = pv
x.InnerField = 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"`
FieldAux []RepPrimitives_Aux `json:"fieldAux"`
}
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]))
}
for i := range x.FieldAux {
size += proto.NestedStructureSizeUnchecked(8, &x.FieldAux[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])
}
for i := range x.FieldAux {
x.FieldAux[i].EmitProtobuf(mm.AppendMessage(8))
}
}
// 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)
case 8: // FieldAux
data, ok := fc.MessageData()
if !ok {
return fmt.Errorf("cannot unmarshal field %s", "FieldAux")
}
x.FieldAux = append(x.FieldAux, RepPrimitives_Aux{})
ff := &x.FieldAux[len(x.FieldAux)-1]
if err := ff.UnmarshalProtobuf(data); err != nil {
return fmt.Errorf("unmarshal: %w", err)
}
}
}
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
}
func (x *RepPrimitives) GetFieldAux() []RepPrimitives_Aux {
if x != nil {
return x.FieldAux
}
return nil
}
func (x *RepPrimitives) SetFieldAux(v []RepPrimitives_Aux) {
x.FieldAux = 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
}
first := true
out.RawByte('{')
{
if len(x.FieldA) != 0 {
if !first {
out.RawByte(',')
} else {
first = false
}
const prefix string = "\"fieldA\":"
out.RawString(prefix)
out.RawByte('[')
for i := range x.FieldA {
if i != 0 {
out.RawByte(',')
}
out.Base64Bytes(x.FieldA[i])
}
out.RawByte(']')
}
}
{
if len(x.FieldB) != 0 {
if !first {
out.RawByte(',')
} else {
first = false
}
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(']')
}
}
{
if len(x.FieldC) != 0 {
if !first {
out.RawByte(',')
} else {
first = false
}
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(']')
}
}
{
if len(x.FieldD) != 0 {
if !first {
out.RawByte(',')
} else {
first = false
}
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(']')
}
}
{
if len(x.FieldE) != 0 {
if !first {
out.RawByte(',')
} else {
first = false
}
const prefix string = "\"fieldE\":"
out.RawString(prefix)
out.RawByte('[')
for i := range x.FieldE {
if i != 0 {
out.RawByte(',')
}
out.RawByte('"')
out.Buffer.Buf = strconv.AppendInt(out.Buffer.Buf, x.FieldE[i], 10)
out.RawByte('"')
}
out.RawByte(']')
}
}
{
if len(x.FieldF) != 0 {
if !first {
out.RawByte(',')
} else {
first = false
}
const prefix string = "\"fieldF\":"
out.RawString(prefix)
out.RawByte('[')
for i := range x.FieldF {
if i != 0 {
out.RawByte(',')
}
out.RawByte('"')
out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.FieldF[i], 10)
out.RawByte('"')
}
out.RawByte(']')
}
}
{
if len(x.FieldFu) != 0 {
if !first {
out.RawByte(',')
} else {
first = false
}
const prefix string = "\"fieldFu\":"
out.RawString(prefix)
out.RawByte('[')
for i := range x.FieldFu {
if i != 0 {
out.RawByte(',')
}
out.RawByte('"')
out.Buffer.Buf = strconv.AppendUint(out.Buffer.Buf, x.FieldFu[i], 10)
out.RawByte('"')
}
out.RawByte(']')
}
}
{
if len(x.FieldAux) != 0 {
if !first {
out.RawByte(',')
} else {
first = false
}
const prefix string = "\"fieldAux\":"
out.RawString(prefix)
out.RawByte('[')
for i := range x.FieldAux {
if i != 0 {
out.RawByte(',')
}
x.FieldAux[i].MarshalEasyJSON(out)
}
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(']') {
r := in.JsonNumber()
n := r.String()
v, err := strconv.ParseInt(n, 10, 32)
if err != nil {
in.AddError(err)
return
}
pv := int32(v)
f = pv
list = append(list, f)
in.WantComma()
}
x.FieldC = list
in.Delim(']')
}
case "fieldD":
{
var f uint32
var list []uint32
in.Delim('[')
for !in.IsDelim(']') {
r := in.JsonNumber()
n := r.String()
v, err := strconv.ParseUint(n, 10, 32)
if err != nil {
in.AddError(err)
return
}
pv := uint32(v)
f = pv
list = append(list, f)
in.WantComma()
}
x.FieldD = list
in.Delim(']')
}
case "fieldE":
{
var f int64
var list []int64
in.Delim('[')
for !in.IsDelim(']') {
r := in.JsonNumber()
n := r.String()
v, err := strconv.ParseInt(n, 10, 64)
if err != nil {
in.AddError(err)
return
}
pv := int64(v)
f = pv
list = append(list, f)
in.WantComma()
}
x.FieldE = list
in.Delim(']')
}
case "fieldF":
{
var f uint64
var list []uint64
in.Delim('[')
for !in.IsDelim(']') {
r := in.JsonNumber()
n := r.String()
v, err := strconv.ParseUint(n, 10, 64)
if err != nil {
in.AddError(err)
return
}
pv := uint64(v)
f = pv
list = append(list, f)
in.WantComma()
}
x.FieldF = list
in.Delim(']')
}
case "fieldFu":
{
var f uint64
var list []uint64
in.Delim('[')
for !in.IsDelim(']') {
r := in.JsonNumber()
n := r.String()
v, err := strconv.ParseUint(n, 10, 64)
if err != nil {
in.AddError(err)
return
}
pv := uint64(v)
f = pv
list = append(list, f)
in.WantComma()
}
x.FieldFu = list
in.Delim(']')
}
case "fieldAux":
{
var f RepPrimitives_Aux
var list []RepPrimitives_Aux
in.Delim('[')
for !in.IsDelim(']') {
f = RepPrimitives_Aux{}
f.UnmarshalEasyJSON(in)
list = append(list, f)
in.WantComma()
}
x.FieldAux = list
in.Delim(']')
}
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}