Debian Codegraph @

pdata/internal/generated_proto_exportprofilesserviceresponse.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 // Code generated by "internal/cmd/pdatagen/main.go". DO NOT EDIT.
5 // To regenerate this file run "make genpdata".
6
7 package internal
8
9 import (
10 "fmt"
11 "sync"
12
13 "go.opentelemetry.io/collector/pdata/internal/json"
14 "go.opentelemetry.io/collector/pdata/internal/proto"
15 )
16
17 // ExportResponse represents the response for gRPC/HTTP client/server.
18 type ExportProfilesServiceResponse struct {
19 PartialSuccess ExportProfilesPartialSuccess
20 }
21
22 var (
23 protoPoolExportProfilesServiceResponse = sync.Pool{
24 New: func() any {
25 return &ExportProfilesServiceResponse{}
26 },
27 }
28 )
29
30 func NewExportProfilesServiceResponse() *ExportProfilesServiceResponse {
31 if !UseProtoPooling.IsEnabled() {
32 return &ExportProfilesServiceResponse{}
33 }
34 return protoPoolExportProfilesServiceResponse.Get().(*ExportProfilesServiceResponse)
35 }
36
37 func DeleteExportProfilesServiceResponse(orig *ExportProfilesServiceResponse, nullable bool) {
38 if orig == nil {
39 return
40 }
41
42 if !UseProtoPooling.IsEnabled() {
43 orig.Reset()
44 return
45 }
46
47 DeleteExportProfilesPartialSuccess(&orig.PartialSuccess, false)
48
49 orig.Reset()
50 if nullable {
51 protoPoolExportProfilesServiceResponse.Put(orig)
52 }
53 }
54
55 func CopyExportProfilesServiceResponse(dest, src *ExportProfilesServiceResponse) *ExportProfilesServiceResponse {
56 // If copying to same object, just return.
57 if src == dest {
58 return dest
59 }
60
61 if src == nil {
62 return nil
63 }
64
65 if dest == nil {
66 dest = NewExportProfilesServiceResponse()
67 }
68 CopyExportProfilesPartialSuccess(&dest.PartialSuccess, &src.PartialSuccess)
69
70 return dest
71 }
72
73 func CopyExportProfilesServiceResponseSlice(dest, src []ExportProfilesServiceResponse) []ExportProfilesServiceResponse {
74 var newDest []ExportProfilesServiceResponse
75 if cap(dest) < len(src) {
76 newDest = make([]ExportProfilesServiceResponse, len(src))
77 } else {
78 newDest = dest[:len(src)]
79 // Cleanup the rest of the elements so GC can free the memory.
80 // This can happen when len(src) < len(dest) < cap(dest).
81 for i := len(src); i < len(dest); i++ {
82 DeleteExportProfilesServiceResponse(&dest[i], false)
83 }
84 }
85 for i := range src {
86 CopyExportProfilesServiceResponse(&newDest[i], &src[i])
87 }
88 return newDest
89 }
90
91 func CopyExportProfilesServiceResponsePtrSlice(dest, src []*ExportProfilesServiceResponse) []*ExportProfilesServiceResponse {
92 var newDest []*ExportProfilesServiceResponse
93 if cap(dest) < len(src) {
94 newDest = make([]*ExportProfilesServiceResponse, len(src))
95 // Copy old pointers to re-use.
96 copy(newDest, dest)
97 // Add new pointers for missing elements from len(dest) to len(srt).
98 for i := len(dest); i < len(src); i++ {
99 newDest[i] = NewExportProfilesServiceResponse()
100 }
101 } else {
102 newDest = dest[:len(src)]
103 // Cleanup the rest of the elements so GC can free the memory.
104 // This can happen when len(src) < len(dest) < cap(dest).
105 for i := len(src); i < len(dest); i++ {
106 DeleteExportProfilesServiceResponse(dest[i], true)
107 dest[i] = nil
108 }
109 // Add new pointers for missing elements.
110 // This can happen when len(dest) < len(src) < cap(dest).
111 for i := len(dest); i < len(src); i++ {
112 newDest[i] = NewExportProfilesServiceResponse()
113 }
114 }
115 for i := range src {
116 CopyExportProfilesServiceResponse(newDest[i], src[i])
117 }
118 return newDest
119 }
120
121 func (orig *ExportProfilesServiceResponse) Reset() {
122 *orig = ExportProfilesServiceResponse{}
123 }
124
125 // MarshalJSON marshals all properties from the current struct to the destination stream.
126 func (orig *ExportProfilesServiceResponse) MarshalJSON(dest *json.Stream) {
127 dest.WriteObjectStart()
128 dest.WriteObjectField("partialSuccess")
129 orig.PartialSuccess.MarshalJSON(dest)
130 dest.WriteObjectEnd()
131 }
132
133 // UnmarshalJSON unmarshals all properties from the current struct from the source iterator.
134 func (orig *ExportProfilesServiceResponse) UnmarshalJSON(iter *json.Iterator) {
135 for f := iter.ReadObject(); f != ""; f = iter.ReadObject() {
136 switch f {
137 case "partialSuccess", "partial_success":
138
139 orig.PartialSuccess.UnmarshalJSON(iter)
140 default:
141 iter.Skip()
142 }
143 }
144 }
145
146 func (orig *ExportProfilesServiceResponse) SizeProto() int {
147 var n int
148 var l int
149 _ = l
150 l = orig.PartialSuccess.SizeProto()
151 n += 1 + proto.Sov(uint64(l)) + l
152 return n
153 }
154
155 func (orig *ExportProfilesServiceResponse) MarshalProto(buf []byte) int {
156 pos := len(buf)
157 var l int
158 _ = l
159 l = orig.PartialSuccess.MarshalProto(buf[:pos])
160 pos -= l
161 pos = proto.EncodeVarint(buf, pos, uint64(l))
162 pos--
163 buf[pos] = 0xa
164
165 return len(buf) - pos
166 }
167
168 func (orig *ExportProfilesServiceResponse) UnmarshalProto(buf []byte) error {
169 var err error
170 var fieldNum int32
171 var wireType proto.WireType
172
173 l := len(buf)
174 pos := 0
175 for pos < l {
176 // If in a group parsing, move to the next tag.
177 fieldNum, wireType, pos, err = proto.ConsumeTag(buf, pos)
178 if err != nil {
179 return err
180 }
181 switch fieldNum {
182
183 case 1:
184 if wireType != proto.WireTypeLen {
185 return fmt.Errorf("proto: wrong wireType = %d for field PartialSuccess", wireType)
186 }
187 var length int
188 length, pos, err = proto.ConsumeLen(buf, pos)
189 if err != nil {
190 return err
191 }
192 startPos := pos - length
193
194 err = orig.PartialSuccess.UnmarshalProto(buf[startPos:pos])
195 if err != nil {
196 return err
197 }
198 default:
199 pos, err = proto.ConsumeUnknown(buf, pos, wireType)
200 if err != nil {
201 return err
202 }
203 }
204 }
205 return nil
206 }
207
208 func GenTestExportProfilesServiceResponse() *ExportProfilesServiceResponse {
209 orig := NewExportProfilesServiceResponse()
210 orig.PartialSuccess = *GenTestExportProfilesPartialSuccess()
211 return orig
212 }
213
214 func GenTestExportProfilesServiceResponsePtrSlice() []*ExportProfilesServiceResponse {
215 orig := make([]*ExportProfilesServiceResponse, 5)
216 orig[0] = NewExportProfilesServiceResponse()
217 orig[1] = GenTestExportProfilesServiceResponse()
218 orig[2] = NewExportProfilesServiceResponse()
219 orig[3] = GenTestExportProfilesServiceResponse()
220 orig[4] = NewExportProfilesServiceResponse()
221 return orig
222 }
223
224 func GenTestExportProfilesServiceResponseSlice() []ExportProfilesServiceResponse {
225 orig := make([]ExportProfilesServiceResponse, 5)
226 orig[1] = *GenTestExportProfilesServiceResponse()
227 orig[3] = *GenTestExportProfilesServiceResponse()
228 return orig
229 }