/
uniqueid.vdl.go
81 lines (65 loc) · 2.05 KB
/
uniqueid.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
// 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: uniqueid
//nolint:golint
package uniqueid
import (
"v.io/v23/vdl"
)
var _ = initializeVDL() // Must be first; see initializeVDL comments for details.
// Type definitions
// ================
// An Id is a likely globally unique identifier.
type Id [16]byte
func (Id) VDLReflect(struct {
Name string `vdl:"v.io/v23/uniqueid.Id"`
}) {
}
func (x Id) VDLIsZero() bool { //nolint:gocyclo
return x == Id{}
}
func (x Id) VDLWrite(enc vdl.Encoder) error { //nolint:gocyclo
if err := enc.WriteValueBytes(vdlTypeArray1, x[:]); err != nil {
return err
}
return nil
}
func (x *Id) VDLRead(dec vdl.Decoder) error { //nolint:gocyclo
bytes := x[:]
if err := dec.ReadValueBytes(16, &bytes); err != nil {
return err
}
return nil
}
// Hold type definitions in package-level variables, for better performance.
//nolint:unused
var (
vdlTypeArray1 *vdl.Type
)
var initializeVDLCalled bool
// initializeVDL 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 _ = initializeVDL()
//
// 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 initializeVDL() struct{} {
if initializeVDLCalled {
return struct{}{}
}
initializeVDLCalled = true
// Register types.
vdl.Register((*Id)(nil))
// Initialize type definitions.
vdlTypeArray1 = vdl.TypeOf((*Id)(nil))
return struct{}{}
}