-
Notifications
You must be signed in to change notification settings - Fork 8
/
naming.vdl.go
694 lines (643 loc) · 17 KB
/
naming.vdl.go
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
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file was auto-generated by the vanadium vdl tool.
// Package: naming
package naming
import (
"fmt"
"v.io/v23/vdl"
vdltime "v.io/v23/vdlroot/time"
"v.io/v23/verror"
)
var _ = __VDLInit() // Must be first; see __VDLInit comments for details.
//////////////////////////////////////////////////
// Type definitions
// MountFlag is a bit mask of options to the mount call.
type MountFlag uint32
func (MountFlag) VDLReflect(struct {
Name string `vdl:"v.io/v23/naming.MountFlag"`
}) {
}
func (x MountFlag) VDLIsZero() bool {
return x == 0
}
func (x MountFlag) VDLWrite(enc vdl.Encoder) error {
if err := enc.WriteValueUint(__VDLType_uint32_1, uint64(x)); err != nil {
return err
}
return nil
}
func (x *MountFlag) VDLRead(dec vdl.Decoder) error {
switch value, err := dec.ReadValueUint(32); {
case err != nil:
return err
default:
*x = MountFlag(value)
}
return nil
}
// MountedServer represents a server mounted on a specific name.
type MountedServer struct {
// Server is the OA that's mounted.
Server string
// Deadline before the mount entry expires.
Deadline vdltime.Deadline
}
func (MountedServer) VDLReflect(struct {
Name string `vdl:"v.io/v23/naming.MountedServer"`
}) {
}
func (x MountedServer) VDLIsZero() bool {
if x.Server != "" {
return false
}
if !x.Deadline.Time.IsZero() {
return false
}
return true
}
func (x MountedServer) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_struct_2); err != nil {
return err
}
if x.Server != "" {
if err := enc.NextFieldValueString(0, vdl.StringType, x.Server); err != nil {
return err
}
}
if !x.Deadline.Time.IsZero() {
if err := enc.NextField(1); err != nil {
return err
}
var wire vdltime.WireDeadline
if err := vdltime.WireDeadlineFromNative(&wire, x.Deadline); err != nil {
return err
}
if err := wire.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextField(-1); err != nil {
return err
}
return enc.FinishValue()
}
func (x *MountedServer) VDLRead(dec vdl.Decoder) error {
*x = MountedServer{}
if err := dec.StartValue(__VDLType_struct_2); err != nil {
return err
}
decType := dec.Type()
for {
index, err := dec.NextField()
switch {
case err != nil:
return err
case index == -1:
return dec.FinishValue()
}
if decType != __VDLType_struct_2 {
index = __VDLType_struct_2.FieldIndexByName(decType.Field(index).Name)
if index == -1 {
if err := dec.SkipValue(); err != nil {
return err
}
continue
}
}
switch index {
case 0:
switch value, err := dec.ReadValueString(); {
case err != nil:
return err
default:
x.Server = value
}
case 1:
var wire vdltime.WireDeadline
if err := wire.VDLRead(dec); err != nil {
return err
}
if err := vdltime.WireDeadlineToNative(wire, &x.Deadline); err != nil {
return err
}
}
}
}
// MountEntry represents a given name mounted in the mounttable.
type MountEntry struct {
// Name is the mounted name.
Name string
// Servers (if present) specifies the mounted names.
Servers []MountedServer
// ServesMountTable is true if the servers represent mount tables.
ServesMountTable bool
// IsLeaf is true if this entry represents a leaf object.
IsLeaf bool
}
func (MountEntry) VDLReflect(struct {
Name string `vdl:"v.io/v23/naming.MountEntry"`
}) {
}
func (x MountEntry) VDLIsZero() bool {
if x.Name != "" {
return false
}
if len(x.Servers) != 0 {
return false
}
if x.ServesMountTable {
return false
}
if x.IsLeaf {
return false
}
return true
}
func (x MountEntry) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_struct_4); err != nil {
return err
}
if x.Name != "" {
if err := enc.NextFieldValueString(0, vdl.StringType, x.Name); err != nil {
return err
}
}
if len(x.Servers) != 0 {
if err := enc.NextField(1); err != nil {
return err
}
if err := __VDLWriteAnon_list_1(enc, x.Servers); err != nil {
return err
}
}
if x.ServesMountTable {
if err := enc.NextFieldValueBool(2, vdl.BoolType, x.ServesMountTable); err != nil {
return err
}
}
if x.IsLeaf {
if err := enc.NextFieldValueBool(3, vdl.BoolType, x.IsLeaf); err != nil {
return err
}
}
if err := enc.NextField(-1); err != nil {
return err
}
return enc.FinishValue()
}
func __VDLWriteAnon_list_1(enc vdl.Encoder, x []MountedServer) error {
if err := enc.StartValue(__VDLType_list_5); err != nil {
return err
}
if err := enc.SetLenHint(len(x)); err != nil {
return err
}
for _, elem := range x {
if err := enc.NextEntry(false); err != nil {
return err
}
if err := elem.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextEntry(true); err != nil {
return err
}
return enc.FinishValue()
}
func (x *MountEntry) VDLRead(dec vdl.Decoder) error {
*x = MountEntry{}
if err := dec.StartValue(__VDLType_struct_4); err != nil {
return err
}
decType := dec.Type()
for {
index, err := dec.NextField()
switch {
case err != nil:
return err
case index == -1:
return dec.FinishValue()
}
if decType != __VDLType_struct_4 {
index = __VDLType_struct_4.FieldIndexByName(decType.Field(index).Name)
if index == -1 {
if err := dec.SkipValue(); err != nil {
return err
}
continue
}
}
switch index {
case 0:
switch value, err := dec.ReadValueString(); {
case err != nil:
return err
default:
x.Name = value
}
case 1:
if err := __VDLReadAnon_list_1(dec, &x.Servers); err != nil {
return err
}
case 2:
switch value, err := dec.ReadValueBool(); {
case err != nil:
return err
default:
x.ServesMountTable = value
}
case 3:
switch value, err := dec.ReadValueBool(); {
case err != nil:
return err
default:
x.IsLeaf = value
}
}
}
}
func __VDLReadAnon_list_1(dec vdl.Decoder, x *[]MountedServer) error {
if err := dec.StartValue(__VDLType_list_5); err != nil {
return err
}
if len := dec.LenHint(); len > 0 {
*x = make([]MountedServer, 0, len)
} else {
*x = nil
}
for {
switch done, err := dec.NextEntry(); {
case err != nil:
return err
case done:
return dec.FinishValue()
default:
var elem MountedServer
if err := elem.VDLRead(dec); err != nil {
return err
}
*x = append(*x, elem)
}
}
}
// GlobError is returned by namespace.Glob to indicate a subtree of the namespace
// that could not be traversed.
type GlobError struct {
// Root of the subtree.
Name string
// The error that occurred fulfilling the request.
Error error
}
func (GlobError) VDLReflect(struct {
Name string `vdl:"v.io/v23/naming.GlobError"`
}) {
}
func (x GlobError) VDLIsZero() bool {
return x == GlobError{}
}
func (x GlobError) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_struct_6); err != nil {
return err
}
if x.Name != "" {
if err := enc.NextFieldValueString(0, vdl.StringType, x.Name); err != nil {
return err
}
}
if x.Error != nil {
if err := enc.NextField(1); err != nil {
return err
}
if err := verror.VDLWrite(enc, x.Error); err != nil {
return err
}
}
if err := enc.NextField(-1); err != nil {
return err
}
return enc.FinishValue()
}
func (x *GlobError) VDLRead(dec vdl.Decoder) error {
*x = GlobError{}
if err := dec.StartValue(__VDLType_struct_6); err != nil {
return err
}
decType := dec.Type()
for {
index, err := dec.NextField()
switch {
case err != nil:
return err
case index == -1:
return dec.FinishValue()
}
if decType != __VDLType_struct_6 {
index = __VDLType_struct_6.FieldIndexByName(decType.Field(index).Name)
if index == -1 {
if err := dec.SkipValue(); err != nil {
return err
}
continue
}
}
switch index {
case 0:
switch value, err := dec.ReadValueString(); {
case err != nil:
return err
default:
x.Name = value
}
case 1:
if err := verror.VDLRead(dec, &x.Error); err != nil {
return err
}
}
}
}
type (
// GlobReply represents any single field of the GlobReply union type.
//
// GlobReply is the data type returned by Glob__.
GlobReply interface {
// Index returns the field index.
Index() int
// Interface returns the field value as an interface.
Interface() interface{}
// Name returns the field name.
Name() string
// VDLReflect describes the GlobReply union type.
VDLReflect(__GlobReplyReflect)
VDLIsZero() bool
VDLWrite(vdl.Encoder) error
}
// GlobReplyEntry represents field Entry of the GlobReply union type.
GlobReplyEntry struct{ Value MountEntry }
// GlobReplyError represents field Error of the GlobReply union type.
GlobReplyError struct{ Value GlobError }
// __GlobReplyReflect describes the GlobReply union type.
__GlobReplyReflect struct {
Name string `vdl:"v.io/v23/naming.GlobReply"`
Type GlobReply
Union struct {
Entry GlobReplyEntry
Error GlobReplyError
}
}
)
func (x GlobReplyEntry) Index() int { return 0 }
func (x GlobReplyEntry) Interface() interface{} { return x.Value }
func (x GlobReplyEntry) Name() string { return "Entry" }
func (x GlobReplyEntry) VDLReflect(__GlobReplyReflect) {}
func (x GlobReplyError) Index() int { return 1 }
func (x GlobReplyError) Interface() interface{} { return x.Value }
func (x GlobReplyError) Name() string { return "Error" }
func (x GlobReplyError) VDLReflect(__GlobReplyReflect) {}
func (x GlobReplyEntry) VDLIsZero() bool {
return x.Value.VDLIsZero()
}
func (x GlobReplyError) VDLIsZero() bool {
return false
}
func (x GlobReplyEntry) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_union_7); err != nil {
return err
}
if err := enc.NextField(0); err != nil {
return err
}
if err := x.Value.VDLWrite(enc); err != nil {
return err
}
if err := enc.NextField(-1); err != nil {
return err
}
return enc.FinishValue()
}
func (x GlobReplyError) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_union_7); err != nil {
return err
}
if err := enc.NextField(1); err != nil {
return err
}
if err := x.Value.VDLWrite(enc); err != nil {
return err
}
if err := enc.NextField(-1); err != nil {
return err
}
return enc.FinishValue()
}
func VDLReadGlobReply(dec vdl.Decoder, x *GlobReply) error {
if err := dec.StartValue(__VDLType_union_7); err != nil {
return err
}
decType := dec.Type()
index, err := dec.NextField()
switch {
case err != nil:
return err
case index == -1:
return fmt.Errorf("missing field in union %T, from %v", x, decType)
}
if decType != __VDLType_union_7 {
name := decType.Field(index).Name
index = __VDLType_union_7.FieldIndexByName(name)
if index == -1 {
return fmt.Errorf("field %q not in union %T, from %v", name, x, decType)
}
}
switch index {
case 0:
var field GlobReplyEntry
if err := field.Value.VDLRead(dec); err != nil {
return err
}
*x = field
case 1:
var field GlobReplyError
if err := field.Value.VDLRead(dec); err != nil {
return err
}
*x = field
}
switch index, err := dec.NextField(); {
case err != nil:
return err
case index != -1:
return fmt.Errorf("extra field %d in union %T, from %v", index, x, dec.Type())
}
return dec.FinishValue()
}
type (
// GlobChildrenReply represents any single field of the GlobChildrenReply union type.
//
// GlobChildrenReply is the data type returned by GlobChildren__.
GlobChildrenReply interface {
// Index returns the field index.
Index() int
// Interface returns the field value as an interface.
Interface() interface{}
// Name returns the field name.
Name() string
// VDLReflect describes the GlobChildrenReply union type.
VDLReflect(__GlobChildrenReplyReflect)
VDLIsZero() bool
VDLWrite(vdl.Encoder) error
}
// GlobChildrenReplyName represents field Name of the GlobChildrenReply union type.
GlobChildrenReplyName struct{ Value string }
// GlobChildrenReplyError represents field Error of the GlobChildrenReply union type.
GlobChildrenReplyError struct{ Value GlobError }
// __GlobChildrenReplyReflect describes the GlobChildrenReply union type.
__GlobChildrenReplyReflect struct {
Name string `vdl:"v.io/v23/naming.GlobChildrenReply"`
Type GlobChildrenReply
Union struct {
Name GlobChildrenReplyName
Error GlobChildrenReplyError
}
}
)
func (x GlobChildrenReplyName) Index() int { return 0 }
func (x GlobChildrenReplyName) Interface() interface{} { return x.Value }
func (x GlobChildrenReplyName) Name() string { return "Name" }
func (x GlobChildrenReplyName) VDLReflect(__GlobChildrenReplyReflect) {}
func (x GlobChildrenReplyError) Index() int { return 1 }
func (x GlobChildrenReplyError) Interface() interface{} { return x.Value }
func (x GlobChildrenReplyError) Name() string { return "Error" }
func (x GlobChildrenReplyError) VDLReflect(__GlobChildrenReplyReflect) {}
func (x GlobChildrenReplyName) VDLIsZero() bool {
return x.Value == ""
}
func (x GlobChildrenReplyError) VDLIsZero() bool {
return false
}
func (x GlobChildrenReplyName) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_union_8); err != nil {
return err
}
if err := enc.NextFieldValueString(0, vdl.StringType, x.Value); err != nil {
return err
}
if err := enc.NextField(-1); err != nil {
return err
}
return enc.FinishValue()
}
func (x GlobChildrenReplyError) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_union_8); err != nil {
return err
}
if err := enc.NextField(1); err != nil {
return err
}
if err := x.Value.VDLWrite(enc); err != nil {
return err
}
if err := enc.NextField(-1); err != nil {
return err
}
return enc.FinishValue()
}
func VDLReadGlobChildrenReply(dec vdl.Decoder, x *GlobChildrenReply) error {
if err := dec.StartValue(__VDLType_union_8); err != nil {
return err
}
decType := dec.Type()
index, err := dec.NextField()
switch {
case err != nil:
return err
case index == -1:
return fmt.Errorf("missing field in union %T, from %v", x, decType)
}
if decType != __VDLType_union_8 {
name := decType.Field(index).Name
index = __VDLType_union_8.FieldIndexByName(name)
if index == -1 {
return fmt.Errorf("field %q not in union %T, from %v", name, x, decType)
}
}
switch index {
case 0:
var field GlobChildrenReplyName
switch value, err := dec.ReadValueString(); {
case err != nil:
return err
default:
field.Value = value
}
*x = field
case 1:
var field GlobChildrenReplyError
if err := field.Value.VDLRead(dec); err != nil {
return err
}
*x = field
}
switch index, err := dec.NextField(); {
case err != nil:
return err
case index != -1:
return fmt.Errorf("extra field %d in union %T, from %v", index, x, dec.Type())
}
return dec.FinishValue()
}
//////////////////////////////////////////////////
// Const definitions
const Replace = MountFlag(1) // Replace means the mount should replace what is currently at the mount point
const MT = MountFlag(2) // MT means that the target server is a mount table.
const Leaf = MountFlag(4) // Leaf means that the target server is a leaf.
// Hold type definitions in package-level variables, for better performance.
var (
__VDLType_uint32_1 *vdl.Type
__VDLType_struct_2 *vdl.Type
__VDLType_struct_3 *vdl.Type
__VDLType_struct_4 *vdl.Type
__VDLType_list_5 *vdl.Type
__VDLType_struct_6 *vdl.Type
__VDLType_union_7 *vdl.Type
__VDLType_union_8 *vdl.Type
)
var __VDLInitCalled bool
// __VDLInit performs vdl initialization. It is safe to call multiple times.
// If you have an init ordering issue, just insert the following line verbatim
// into your source files in this package, right after the "package foo" clause:
//
// var _ = __VDLInit()
//
// The purpose of this function is to ensure that vdl initialization occurs in
// the right order, and very early in the init sequence. In particular, vdl
// registration and package variable initialization needs to occur before
// functions like vdl.TypeOf will work properly.
//
// This function returns a dummy value, so that it can be used to initialize the
// first var in the file, to take advantage of Go's defined init order.
func __VDLInit() struct{} {
if __VDLInitCalled {
return struct{}{}
}
__VDLInitCalled = true
// Register types.
vdl.Register((*MountFlag)(nil))
vdl.Register((*MountedServer)(nil))
vdl.Register((*MountEntry)(nil))
vdl.Register((*GlobError)(nil))
vdl.Register((*GlobReply)(nil))
vdl.Register((*GlobChildrenReply)(nil))
// Initialize type definitions.
__VDLType_uint32_1 = vdl.TypeOf((*MountFlag)(nil))
__VDLType_struct_2 = vdl.TypeOf((*MountedServer)(nil)).Elem()
__VDLType_struct_3 = vdl.TypeOf((*vdltime.WireDeadline)(nil)).Elem()
__VDLType_struct_4 = vdl.TypeOf((*MountEntry)(nil)).Elem()
__VDLType_list_5 = vdl.TypeOf((*[]MountedServer)(nil))
__VDLType_struct_6 = vdl.TypeOf((*GlobError)(nil)).Elem()
__VDLType_union_7 = vdl.TypeOf((*GlobReply)(nil))
__VDLType_union_8 = vdl.TypeOf((*GlobChildrenReply)(nil))
return struct{}{}
}