~bigbes/tarantool

tarantool-protobuf

ref: fde45f1ef7af07069489ba49087d926d76511721 tarantool-protobuf/examples/expected/full/conformance/conformance_pb.lua -rw-r--r-- 31.0 KiB
fde45f1e — Eugene Blikh docs: track protobuf editions support as a deferred non-goal 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
-- Code generated by protoc-gen-tarantool. DO NOT EDIT.
-- source: conformance.proto
-- syntax: proto3
-- package: conformance

local pb = require("pb")
local wire = pb.wire

local M = {}

-- Enum: conformance.WireFormat
M.WireFormat_descriptor = pb.enum("conformance.WireFormat", {
    UNSPECIFIED = 0,
    PROTOBUF = 1,
    JSON = 2,
    JSPB = 3,
    TEXT_FORMAT = 4,
})
M.WireFormat = M.WireFormat_descriptor.by_name

-- Enum: conformance.TestCategory
M.TestCategory_descriptor = pb.enum("conformance.TestCategory", {
    UNSPECIFIED_TEST = 0,
    BINARY_TEST = 1,
    JSON_TEST = 2,
    -- Similar to JSON_TEST. However, during parsing json, testee should ignore
    -- unknown fields. This feature is optional. Each implementation can decide
    -- whether to support it.  See
    -- https://developers.google.com/protocol-buffers/docs/proto3#json_options
    -- for more detail.
    JSON_IGNORE_UNKNOWN_PARSING_TEST = 3,
    -- Test jspb wire format. Only used inside Google. Opensource testees just
    -- skip it.
    JSPB_TEST = 4,
    -- Test text format. For cpp, java and python, testees can already deal with
    -- this type. Testees of other languages can simply skip it.
    TEXT_FORMAT_TEST = 5,
})
M.TestCategory = M.TestCategory_descriptor.by_name

-- Pre-declare message descriptors so cross-references resolve.
M.TestStatus_descriptor = {name = "conformance.TestStatus"}
M.FailureSet_descriptor = {name = "conformance.FailureSet"}
M.ConformanceRequest_descriptor = {name = "conformance.ConformanceRequest"}
M.ConformanceResponse_descriptor = {name = "conformance.ConformanceResponse"}
M.JspbEncodingConfig_descriptor = {name = "conformance.JspbEncodingConfig"}

-- Message: conformance.TestStatus
M.TestStatus_descriptor.fields = {
    {name="name", id=1, kind='scalar', proto_type="string"},
    {name="failure_message", id=2, kind='scalar', proto_type="string"},
    {name="matched_name", id=3, kind='scalar', proto_type="string"},
}
pb.finalize_message(M.TestStatus_descriptor)
M.TestStatus_fields = pb.field_names({
    name = "name",
    failure_message = "failure_message",
    matched_name = "matched_name",
})

-- Message: conformance.FailureSet
M.FailureSet_descriptor.fields = {
    {name="test", id=2, kind='message', message=M.TestStatus_descriptor, repeated=true},
}
pb.finalize_message(M.FailureSet_descriptor)
M.FailureSet_fields = pb.field_names({
    test = "test",
})

-- Message: conformance.ConformanceRequest
M.ConformanceRequest_descriptor.fields = {
    {name="protobuf_payload", id=1, kind='scalar', proto_type="bytes", oneof="payload"},
    {name="json_payload", id=2, kind='scalar', proto_type="string", oneof="payload"},
    {name="jspb_payload", id=7, kind='scalar', proto_type="string", oneof="payload"},
    {name="text_payload", id=8, kind='scalar', proto_type="string", oneof="payload"},
    {name="requested_output_format", id=3, kind='enum', enum=M.WireFormat_descriptor},
    {name="message_type", id=4, kind='scalar', proto_type="string"},
    {name="test_category", id=5, kind='enum', enum=M.TestCategory_descriptor},
    {name="jspb_encoding_options", id=6, kind='message', message=M.JspbEncodingConfig_descriptor},
    {name="print_unknown_fields", id=9, kind='scalar', proto_type="bool"},
}
M.ConformanceRequest_descriptor.oneofs = {
    payload = {"protobuf_payload", "json_payload", "jspb_payload", "text_payload"},
}
pb.finalize_message(M.ConformanceRequest_descriptor)
M.ConformanceRequest_fields = pb.field_names({
    protobuf_payload = "protobuf_payload",
    json_payload = "json_payload",
    jspb_payload = "jspb_payload",
    text_payload = "text_payload",
    requested_output_format = "requested_output_format",
    message_type = "message_type",
    test_category = "test_category",
    jspb_encoding_options = "jspb_encoding_options",
    print_unknown_fields = "print_unknown_fields",
})
M.ConformanceRequest_oneofs = pb.field_names({
    payload = "payload",
})

-- Message: conformance.ConformanceResponse
M.ConformanceResponse_descriptor.fields = {
    {name="parse_error", id=1, kind='scalar', proto_type="string", oneof="result"},
    {name="serialize_error", id=6, kind='scalar', proto_type="string", oneof="result"},
    {name="timeout_error", id=9, kind='scalar', proto_type="string", oneof="result"},
    {name="runtime_error", id=2, kind='scalar', proto_type="string", oneof="result"},
    {name="protobuf_payload", id=3, kind='scalar', proto_type="bytes", oneof="result"},
    {name="json_payload", id=4, kind='scalar', proto_type="string", oneof="result"},
    {name="skipped", id=5, kind='scalar', proto_type="string", oneof="result"},
    {name="jspb_payload", id=7, kind='scalar', proto_type="string", oneof="result"},
    {name="text_payload", id=8, kind='scalar', proto_type="string", oneof="result"},
}
M.ConformanceResponse_descriptor.oneofs = {
    result = {"parse_error", "serialize_error", "timeout_error", "runtime_error", "protobuf_payload", "json_payload", "skipped", "jspb_payload", "text_payload"},
}
pb.finalize_message(M.ConformanceResponse_descriptor)
M.ConformanceResponse_fields = pb.field_names({
    parse_error = "parse_error",
    serialize_error = "serialize_error",
    timeout_error = "timeout_error",
    runtime_error = "runtime_error",
    protobuf_payload = "protobuf_payload",
    json_payload = "json_payload",
    skipped = "skipped",
    jspb_payload = "jspb_payload",
    text_payload = "text_payload",
})
M.ConformanceResponse_oneofs = pb.field_names({
    result = "result",
})

-- Message: conformance.JspbEncodingConfig
M.JspbEncodingConfig_descriptor.fields = {
    {name="use_jspb_array_any_format", id=1, kind='scalar', proto_type="bool"},
}
pb.finalize_message(M.JspbEncodingConfig_descriptor)
M.JspbEncodingConfig_fields = pb.field_names({
    use_jspb_array_any_format = "use_jspb_array_any_format",
})

-- EmmyLua / lua-language-server type annotations.
-- These are comments — no runtime effect. They give editors
-- autocomplete and type-checking for the generated wrappers.
---@alias conformance.WireFormat integer
---@alias conformance.TestCategory integer

--- Meant to encapsulate all types of tests: successes, skips, failures, etc.
--- Therefore, this may or may not have a failure message. Failure messages
--- may be truncated for our failure lists.
---@class conformance.TestStatus
---@field name string
---@field failure_message string
---@field matched_name string @ What an actual test name matched to in a failure list. Can be wildcarded or an exact match without wildcards.

--- The conformance runner will request a list of failures as the first request.
--- This will be known by message_type == "conformance.FailureSet", a conformance
--- test should return a serialized FailureSet in protobuf_payload.
---@class conformance.FailureSet
---@field test conformance.TestStatus[]

--- Represents a single test case's input.  The testee should:
---
---   1. parse this proto (which should always succeed)
---   2. parse the protobuf or JSON payload in "payload" (which may fail)
---   3. if the parse succeeded, serialize the message in the requested format.
---@class conformance.ConformanceRequest
---@field protobuf_payload? string
---@field json_payload? string
---@field jspb_payload? string @ Only used inside Google.  Opensource testees just skip it.
---@field text_payload? string
---@field requested_output_format conformance.WireFormat @ Which format should the testee serialize its message to?
---@field message_type string @ The full name for the test message to use; for the moment, either: protobuf_test_messages.proto3.TestAllTypesProto3 or protobuf_test_messages.proto2.TestAllTypesProto2 or protobuf_test_messages.editions.proto2.TestAllTypesProto2 or protobuf_test_messages.editions.proto3.TestAllTypesProto3 or protobuf_test_messages.editions.TestAllTypesEdition2023 or protobuf_test_messages.edition_unstable.TestAllTypesEditionUnstable.
---@field test_category conformance.TestCategory @ Each test is given a specific test category. Some category may need specific support in testee programs. Refer to the definition of TestCategory for more information.
---@field jspb_encoding_options conformance.JspbEncodingConfig @ Specify details for how to encode jspb.
---@field print_unknown_fields boolean @ This can be used in json and text format. If true, testee should print unknown fields instead of ignore. This feature is optional.

--- Represents a single test case's output.
---@class conformance.ConformanceResponse
---@field parse_error? string @ This string should be set to indicate parsing failed.  The string can provide more information about the parse error if it is available.  Setting this string does not necessarily mean the testee failed the test.  Some of the test cases are intentionally invalid input.
---@field serialize_error? string @ If the input was successfully parsed but errors occurred when serializing it to the requested output format, set the error message in this field.
---@field timeout_error? string @ This should be set if the test program timed out.  The string should provide more information about what the child process was doing when it was killed.
---@field runtime_error? string @ This should be set if some other error occurred.  This will always indicate that the test failed.  The string can provide more information about the failure.
---@field protobuf_payload? string @ If the input was successfully parsed and the requested output was protobuf, serialize it to protobuf and set it in this field.
---@field json_payload? string @ If the input was successfully parsed and the requested output was JSON, serialize to JSON and set it in this field.
---@field skipped? string @ For when the testee skipped the test, likely because a certain feature wasn't supported, like JSON input/output.
---@field jspb_payload? string @ If the input was successfully parsed and the requested output was JSPB, serialize to JSPB and set it in this field. JSPB is only used inside Google. Opensource testees can just skip it.
---@field text_payload? string @ If the input was successfully parsed and the requested output was TEXT_FORMAT, serialize to TEXT_FORMAT and set it in this field.

--- Encoding options for jspb format.
---@class conformance.JspbEncodingConfig
---@field use_jspb_array_any_format boolean @ Encode the value field of Any as jspb array if true, otherwise binary.

---@param t? conformance.TestStatus
---@return conformance.TestStatus
function M.TestStatus_new(t) return t or {} end

---@param t conformance.TestStatus
---@return string
function M.TestStatus_encode(t)
    if type(t) ~= 'table' then
        error("expected table for conformance.TestStatus, got " .. type(t), 0)
    end
    local out, n = {}, 0
    local v
    -- field 1: name
    v = t.name
    if v ~= nil and v ~= '' then
        n = n + 1; out[n] = "\x0a"
        n = n + 1; out[n] = wire.encode_varint(#v)
        n = n + 1; out[n] = v
    end
    -- field 2: failure_message
    v = t.failure_message
    if v ~= nil and v ~= '' then
        n = n + 1; out[n] = "\x12"
        n = n + 1; out[n] = wire.encode_varint(#v)
        n = n + 1; out[n] = v
    end
    -- field 3: matched_name
    v = t.matched_name
    if v ~= nil and v ~= '' then
        n = n + 1; out[n] = "\x1a"
        n = n + 1; out[n] = wire.encode_varint(#v)
        n = n + 1; out[n] = v
    end
    local _uf = t._unknown_fields
    if _uf ~= nil and _uf ~= '' then n = n + 1; out[n] = _uf end
    return table.concat(out)
end

---@param b string
---@return conformance.TestStatus
function M.TestStatus_decode(buf)
    if type(buf) ~= 'string' then
        error("expected string for conformance.TestStatus decode, got " .. type(buf), 0)
    end
    local result = {}
    local pos, len = 1, #buf
    local _uf
    while pos <= len do
        local _tag_start = pos
        local id, wt
        id, wt, pos = wire.decode_tag(buf, pos)
        if id == 1 then
            local val
            val, pos = wire.decode_string(buf, pos)
            result.name = val
        elseif id == 2 then
            local val
            val, pos = wire.decode_string(buf, pos)
            result.failure_message = val
        elseif id == 3 then
            local val
            val, pos = wire.decode_string(buf, pos)
            result.matched_name = val
        else
            pos = wire.skip_field(buf, pos, wt, id)
            if _uf == nil then _uf = {} end
            _uf[#_uf + 1] = buf:sub(_tag_start, pos - 1)
        end
    end
    if _uf ~= nil then result._unknown_fields = table.concat(_uf) end
    return result
end

---@param b string
---@return pb.MessageView
function M.TestStatus_decode_lazy(b) return pb.decode_lazy(M.TestStatus_descriptor, b) end
---@param t conformance.TestStatus
---@param opts? {single_line: boolean?, indent: string?}
---@return string
function M.TestStatus_text(t, opts) return pb.text.encode(M.TestStatus_descriptor, t, opts) end

---@param t? conformance.FailureSet
---@return conformance.FailureSet
function M.FailureSet_new(t) return t or {} end

---@param t conformance.FailureSet
---@return string
function M.FailureSet_encode(t)
    if type(t) ~= 'table' then
        error("expected table for conformance.FailureSet, got " .. type(t), 0)
    end
    local out, n = {}, 0
    local v
    -- field 2: test
    v = t.test
    if v ~= nil and #v > 0 then
        local _tag = "\x12"
        for _i = 1, #v do
            local _b = M.TestStatus_encode(v[_i])
            n = n + 1; out[n] = _tag
            n = n + 1; out[n] = wire.encode_varint(#_b)
            n = n + 1; out[n] = _b
        end
    end
    local _uf = t._unknown_fields
    if _uf ~= nil and _uf ~= '' then n = n + 1; out[n] = _uf end
    return table.concat(out)
end

---@param b string
---@return conformance.FailureSet
function M.FailureSet_decode(buf)
    if type(buf) ~= 'string' then
        error("expected string for conformance.FailureSet decode, got " .. type(buf), 0)
    end
    local result = {}
    local pos, len = 1, #buf
    local _uf
    while pos <= len do
        local _tag_start = pos
        local id, wt
        id, wt, pos = wire.decode_tag(buf, pos)
        if id == 2 then
            local list = result.test
            if list == nil then list = {}; result.test = list end
            local payload
            payload, pos = wire.decode_len(buf, pos)
            list[#list + 1] = M.TestStatus_decode(payload)
        else
            pos = wire.skip_field(buf, pos, wt, id)
            if _uf == nil then _uf = {} end
            _uf[#_uf + 1] = buf:sub(_tag_start, pos - 1)
        end
    end
    if _uf ~= nil then result._unknown_fields = table.concat(_uf) end
    return result
end

---@param b string
---@return pb.MessageView
function M.FailureSet_decode_lazy(b) return pb.decode_lazy(M.FailureSet_descriptor, b) end
---@param t conformance.FailureSet
---@param opts? {single_line: boolean?, indent: string?}
---@return string
function M.FailureSet_text(t, opts) return pb.text.encode(M.FailureSet_descriptor, t, opts) end

---@param t? conformance.ConformanceRequest
---@return conformance.ConformanceRequest
function M.ConformanceRequest_new(t) return t or {} end

---@param t conformance.ConformanceRequest
---@return string
function M.ConformanceRequest_encode(t)
    if type(t) ~= 'table' then
        error("expected table for conformance.ConformanceRequest, got " .. type(t), 0)
    end
    local out, n = {}, 0
    local v
    local _of_payload
    if t.protobuf_payload ~= nil then _of_payload = "protobuf_payload" end
    if t.json_payload ~= nil then _of_payload = "json_payload" end
    if t.jspb_payload ~= nil then _of_payload = "jspb_payload" end
    if t.text_payload ~= nil then _of_payload = "text_payload" end
    -- field 1: protobuf_payload
    v = t.protobuf_payload
    if _of_payload == "protobuf_payload" then
        n = n + 1; out[n] = "\x0a"
        n = n + 1; out[n] = wire.encode_varint(#v)
        n = n + 1; out[n] = v
    end
    -- field 2: json_payload
    v = t.json_payload
    if _of_payload == "json_payload" then
        n = n + 1; out[n] = "\x12"
        n = n + 1; out[n] = wire.encode_varint(#v)
        n = n + 1; out[n] = v
    end
    -- field 7: jspb_payload
    v = t.jspb_payload
    if _of_payload == "jspb_payload" then
        n = n + 1; out[n] = "\x3a"
        n = n + 1; out[n] = wire.encode_varint(#v)
        n = n + 1; out[n] = v
    end
    -- field 8: text_payload
    v = t.text_payload
    if _of_payload == "text_payload" then
        n = n + 1; out[n] = "\x42"
        n = n + 1; out[n] = wire.encode_varint(#v)
        n = n + 1; out[n] = v
    end
    -- field 3: requested_output_format
    v = t.requested_output_format
    if v ~= nil then
        local nv = v
        if type(v) == 'string' then
            nv = M.WireFormat[v]
            if nv == nil then error("unknown enum value '" .. v .. "' for conformance.WireFormat", 0) end
        end
        if nv ~= 0 then
            n = n + 1; out[n] = "\x18"
            n = n + 1; out[n] = wire.encode_int32(nv)
        end
    end
    -- field 4: message_type
    v = t.message_type
    if v ~= nil and v ~= '' then
        n = n + 1; out[n] = "\x22"
        n = n + 1; out[n] = wire.encode_varint(#v)
        n = n + 1; out[n] = v
    end
    -- field 5: test_category
    v = t.test_category
    if v ~= nil then
        local nv = v
        if type(v) == 'string' then
            nv = M.TestCategory[v]
            if nv == nil then error("unknown enum value '" .. v .. "' for conformance.TestCategory", 0) end
        end
        if nv ~= 0 then
            n = n + 1; out[n] = "\x28"
            n = n + 1; out[n] = wire.encode_int32(nv)
        end
    end
    -- field 6: jspb_encoding_options
    v = t.jspb_encoding_options
    if v ~= nil or type(v) == 'cdata' then
        local _b = M.JspbEncodingConfig_encode(v)
        n = n + 1; out[n] = "\x32"
        n = n + 1; out[n] = wire.encode_varint(#_b)
        n = n + 1; out[n] = _b
    end
    -- field 9: print_unknown_fields
    v = t.print_unknown_fields
    if v ~= nil and v ~= false then
        n = n + 1; out[n] = "\x48"
        n = n + 1; out[n] = wire.encode_bool(v)
    end
    local _uf = t._unknown_fields
    if _uf ~= nil and _uf ~= '' then n = n + 1; out[n] = _uf end
    return table.concat(out)
end

---@param b string
---@return conformance.ConformanceRequest
function M.ConformanceRequest_decode(buf)
    if type(buf) ~= 'string' then
        error("expected string for conformance.ConformanceRequest decode, got " .. type(buf), 0)
    end
    local result = {}
    local pos, len = 1, #buf
    local _uf
    while pos <= len do
        local _tag_start = pos
        local id, wt
        id, wt, pos = wire.decode_tag(buf, pos)
        if id == 1 then
            local val
            val, pos = wire.decode_bytes(buf, pos)
            result.protobuf_payload = val
            result.json_payload = nil
            result.jspb_payload = nil
            result.text_payload = nil
        elseif id == 2 then
            local val
            val, pos = wire.decode_string(buf, pos)
            result.json_payload = val
            result.protobuf_payload = nil
            result.jspb_payload = nil
            result.text_payload = nil
        elseif id == 7 then
            local val
            val, pos = wire.decode_string(buf, pos)
            result.jspb_payload = val
            result.protobuf_payload = nil
            result.json_payload = nil
            result.text_payload = nil
        elseif id == 8 then
            local val
            val, pos = wire.decode_string(buf, pos)
            result.text_payload = val
            result.protobuf_payload = nil
            result.json_payload = nil
            result.jspb_payload = nil
        elseif id == 3 then
            local u
            u, pos = wire.decode_varint(buf, pos)
            result.requested_output_format = wire.varint_to_int32(u)
        elseif id == 4 then
            local val
            val, pos = wire.decode_string(buf, pos)
            result.message_type = val
        elseif id == 5 then
            local u
            u, pos = wire.decode_varint(buf, pos)
            result.test_category = wire.varint_to_int32(u)
        elseif id == 6 then
            local payload
            payload, pos = wire.decode_len(buf, pos)
            local prev = result.jspb_encoding_options
            if prev == nil then
                result.jspb_encoding_options = M.JspbEncodingConfig_decode(payload)
            else
                pb.codec.merge_message(M.JspbEncodingConfig_descriptor, prev, M.JspbEncodingConfig_decode(payload))
            end
        elseif id == 9 then
            local val
            val, pos = wire.decode_bool(buf, pos)
            result.print_unknown_fields = val
        else
            pos = wire.skip_field(buf, pos, wt, id)
            if _uf == nil then _uf = {} end
            _uf[#_uf + 1] = buf:sub(_tag_start, pos - 1)
        end
    end
    if _uf ~= nil then result._unknown_fields = table.concat(_uf) end
    return result
end

---@param b string
---@return pb.MessageView
function M.ConformanceRequest_decode_lazy(b) return pb.decode_lazy(M.ConformanceRequest_descriptor, b) end
---@param t conformance.ConformanceRequest
---@param opts? {single_line: boolean?, indent: string?}
---@return string
function M.ConformanceRequest_text(t, opts) return pb.text.encode(M.ConformanceRequest_descriptor, t, opts) end

---@param t? conformance.ConformanceResponse
---@return conformance.ConformanceResponse
function M.ConformanceResponse_new(t) return t or {} end

---@param t conformance.ConformanceResponse
---@return string
function M.ConformanceResponse_encode(t)
    if type(t) ~= 'table' then
        error("expected table for conformance.ConformanceResponse, got " .. type(t), 0)
    end
    local out, n = {}, 0
    local v
    local _of_result
    if t.parse_error ~= nil then _of_result = "parse_error" end
    if t.serialize_error ~= nil then _of_result = "serialize_error" end
    if t.timeout_error ~= nil then _of_result = "timeout_error" end
    if t.runtime_error ~= nil then _of_result = "runtime_error" end
    if t.protobuf_payload ~= nil then _of_result = "protobuf_payload" end
    if t.json_payload ~= nil then _of_result = "json_payload" end
    if t.skipped ~= nil then _of_result = "skipped" end
    if t.jspb_payload ~= nil then _of_result = "jspb_payload" end
    if t.text_payload ~= nil then _of_result = "text_payload" end
    -- field 1: parse_error
    v = t.parse_error
    if _of_result == "parse_error" then
        n = n + 1; out[n] = "\x0a"
        n = n + 1; out[n] = wire.encode_varint(#v)
        n = n + 1; out[n] = v
    end
    -- field 6: serialize_error
    v = t.serialize_error
    if _of_result == "serialize_error" then
        n = n + 1; out[n] = "\x32"
        n = n + 1; out[n] = wire.encode_varint(#v)
        n = n + 1; out[n] = v
    end
    -- field 9: timeout_error
    v = t.timeout_error
    if _of_result == "timeout_error" then
        n = n + 1; out[n] = "\x4a"
        n = n + 1; out[n] = wire.encode_varint(#v)
        n = n + 1; out[n] = v
    end
    -- field 2: runtime_error
    v = t.runtime_error
    if _of_result == "runtime_error" then
        n = n + 1; out[n] = "\x12"
        n = n + 1; out[n] = wire.encode_varint(#v)
        n = n + 1; out[n] = v
    end
    -- field 3: protobuf_payload
    v = t.protobuf_payload
    if _of_result == "protobuf_payload" then
        n = n + 1; out[n] = "\x1a"
        n = n + 1; out[n] = wire.encode_varint(#v)
        n = n + 1; out[n] = v
    end
    -- field 4: json_payload
    v = t.json_payload
    if _of_result == "json_payload" then
        n = n + 1; out[n] = "\x22"
        n = n + 1; out[n] = wire.encode_varint(#v)
        n = n + 1; out[n] = v
    end
    -- field 5: skipped
    v = t.skipped
    if _of_result == "skipped" then
        n = n + 1; out[n] = "\x2a"
        n = n + 1; out[n] = wire.encode_varint(#v)
        n = n + 1; out[n] = v
    end
    -- field 7: jspb_payload
    v = t.jspb_payload
    if _of_result == "jspb_payload" then
        n = n + 1; out[n] = "\x3a"
        n = n + 1; out[n] = wire.encode_varint(#v)
        n = n + 1; out[n] = v
    end
    -- field 8: text_payload
    v = t.text_payload
    if _of_result == "text_payload" then
        n = n + 1; out[n] = "\x42"
        n = n + 1; out[n] = wire.encode_varint(#v)
        n = n + 1; out[n] = v
    end
    local _uf = t._unknown_fields
    if _uf ~= nil and _uf ~= '' then n = n + 1; out[n] = _uf end
    return table.concat(out)
end

---@param b string
---@return conformance.ConformanceResponse
function M.ConformanceResponse_decode(buf)
    if type(buf) ~= 'string' then
        error("expected string for conformance.ConformanceResponse decode, got " .. type(buf), 0)
    end
    local result = {}
    local pos, len = 1, #buf
    local _uf
    while pos <= len do
        local _tag_start = pos
        local id, wt
        id, wt, pos = wire.decode_tag(buf, pos)
        if id == 1 then
            local val
            val, pos = wire.decode_string(buf, pos)
            result.parse_error = val
            result.serialize_error = nil
            result.timeout_error = nil
            result.runtime_error = nil
            result.protobuf_payload = nil
            result.json_payload = nil
            result.skipped = nil
            result.jspb_payload = nil
            result.text_payload = nil
        elseif id == 6 then
            local val
            val, pos = wire.decode_string(buf, pos)
            result.serialize_error = val
            result.parse_error = nil
            result.timeout_error = nil
            result.runtime_error = nil
            result.protobuf_payload = nil
            result.json_payload = nil
            result.skipped = nil
            result.jspb_payload = nil
            result.text_payload = nil
        elseif id == 9 then
            local val
            val, pos = wire.decode_string(buf, pos)
            result.timeout_error = val
            result.parse_error = nil
            result.serialize_error = nil
            result.runtime_error = nil
            result.protobuf_payload = nil
            result.json_payload = nil
            result.skipped = nil
            result.jspb_payload = nil
            result.text_payload = nil
        elseif id == 2 then
            local val
            val, pos = wire.decode_string(buf, pos)
            result.runtime_error = val
            result.parse_error = nil
            result.serialize_error = nil
            result.timeout_error = nil
            result.protobuf_payload = nil
            result.json_payload = nil
            result.skipped = nil
            result.jspb_payload = nil
            result.text_payload = nil
        elseif id == 3 then
            local val
            val, pos = wire.decode_bytes(buf, pos)
            result.protobuf_payload = val
            result.parse_error = nil
            result.serialize_error = nil
            result.timeout_error = nil
            result.runtime_error = nil
            result.json_payload = nil
            result.skipped = nil
            result.jspb_payload = nil
            result.text_payload = nil
        elseif id == 4 then
            local val
            val, pos = wire.decode_string(buf, pos)
            result.json_payload = val
            result.parse_error = nil
            result.serialize_error = nil
            result.timeout_error = nil
            result.runtime_error = nil
            result.protobuf_payload = nil
            result.skipped = nil
            result.jspb_payload = nil
            result.text_payload = nil
        elseif id == 5 then
            local val
            val, pos = wire.decode_string(buf, pos)
            result.skipped = val
            result.parse_error = nil
            result.serialize_error = nil
            result.timeout_error = nil
            result.runtime_error = nil
            result.protobuf_payload = nil
            result.json_payload = nil
            result.jspb_payload = nil
            result.text_payload = nil
        elseif id == 7 then
            local val
            val, pos = wire.decode_string(buf, pos)
            result.jspb_payload = val
            result.parse_error = nil
            result.serialize_error = nil
            result.timeout_error = nil
            result.runtime_error = nil
            result.protobuf_payload = nil
            result.json_payload = nil
            result.skipped = nil
            result.text_payload = nil
        elseif id == 8 then
            local val
            val, pos = wire.decode_string(buf, pos)
            result.text_payload = val
            result.parse_error = nil
            result.serialize_error = nil
            result.timeout_error = nil
            result.runtime_error = nil
            result.protobuf_payload = nil
            result.json_payload = nil
            result.skipped = nil
            result.jspb_payload = nil
        else
            pos = wire.skip_field(buf, pos, wt, id)
            if _uf == nil then _uf = {} end
            _uf[#_uf + 1] = buf:sub(_tag_start, pos - 1)
        end
    end
    if _uf ~= nil then result._unknown_fields = table.concat(_uf) end
    return result
end

---@param b string
---@return pb.MessageView
function M.ConformanceResponse_decode_lazy(b) return pb.decode_lazy(M.ConformanceResponse_descriptor, b) end
---@param t conformance.ConformanceResponse
---@param opts? {single_line: boolean?, indent: string?}
---@return string
function M.ConformanceResponse_text(t, opts) return pb.text.encode(M.ConformanceResponse_descriptor, t, opts) end

---@param t? conformance.JspbEncodingConfig
---@return conformance.JspbEncodingConfig
function M.JspbEncodingConfig_new(t) return t or {} end

---@param t conformance.JspbEncodingConfig
---@return string
function M.JspbEncodingConfig_encode(t)
    if type(t) ~= 'table' then
        error("expected table for conformance.JspbEncodingConfig, got " .. type(t), 0)
    end
    local out, n = {}, 0
    local v
    -- field 1: use_jspb_array_any_format
    v = t.use_jspb_array_any_format
    if v ~= nil and v ~= false then
        n = n + 1; out[n] = "\x08"
        n = n + 1; out[n] = wire.encode_bool(v)
    end
    local _uf = t._unknown_fields
    if _uf ~= nil and _uf ~= '' then n = n + 1; out[n] = _uf end
    return table.concat(out)
end

---@param b string
---@return conformance.JspbEncodingConfig
function M.JspbEncodingConfig_decode(buf)
    if type(buf) ~= 'string' then
        error("expected string for conformance.JspbEncodingConfig decode, got " .. type(buf), 0)
    end
    local result = {}
    local pos, len = 1, #buf
    local _uf
    while pos <= len do
        local _tag_start = pos
        local id, wt
        id, wt, pos = wire.decode_tag(buf, pos)
        if id == 1 then
            local val
            val, pos = wire.decode_bool(buf, pos)
            result.use_jspb_array_any_format = val
        else
            pos = wire.skip_field(buf, pos, wt, id)
            if _uf == nil then _uf = {} end
            _uf[#_uf + 1] = buf:sub(_tag_start, pos - 1)
        end
    end
    if _uf ~= nil then result._unknown_fields = table.concat(_uf) end
    return result
end

---@param b string
---@return pb.MessageView
function M.JspbEncodingConfig_decode_lazy(b) return pb.decode_lazy(M.JspbEncodingConfig_descriptor, b) end
---@param t conformance.JspbEncodingConfig
---@param opts? {single_line: boolean?, indent: string?}
---@return string
function M.JspbEncodingConfig_text(t, opts) return pb.text.encode(M.JspbEncodingConfig_descriptor, t, opts) end

return M