f1022ccf219432f12406d62effe291bf638806ee
[govpp.git] / binapi / vpe_types / vpe_types.ba.go
1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
2 // versions:
3 //  binapi-generator: v0.5.0-dev
4 //  VPP:              22.02-release
5 // source: /usr/share/vpp/api/core/vpe_types.api.json
6
7 // Package vpe_types contains generated bindings for API file vpe_types.api.
8 //
9 // Contents:
10 //   2 aliases
11 //   1 enum
12 //   1 struct
13 //
14 package vpe_types
15
16 import (
17         "strconv"
18         "time"
19
20         api "git.fd.io/govpp.git/api"
21 )
22
23 // This is a compile-time assertion to ensure that this generated file
24 // is compatible with the GoVPP api package it is being compiled against.
25 // A compilation error at this line likely means your copy of the
26 // GoVPP api package needs to be updated.
27 const _ = api.GoVppAPIPackageIsVersion2
28
29 const (
30         APIFile    = "vpe_types"
31         APIVersion = "1.0.0"
32         VersionCrc = 0x5f754a1c
33 )
34
35 // LogLevel defines enum 'log_level'.
36 type LogLevel uint32
37
38 const (
39         VPE_API_LOG_LEVEL_EMERG    LogLevel = 0
40         VPE_API_LOG_LEVEL_ALERT    LogLevel = 1
41         VPE_API_LOG_LEVEL_CRIT     LogLevel = 2
42         VPE_API_LOG_LEVEL_ERR      LogLevel = 3
43         VPE_API_LOG_LEVEL_WARNING  LogLevel = 4
44         VPE_API_LOG_LEVEL_NOTICE   LogLevel = 5
45         VPE_API_LOG_LEVEL_INFO     LogLevel = 6
46         VPE_API_LOG_LEVEL_DEBUG    LogLevel = 7
47         VPE_API_LOG_LEVEL_DISABLED LogLevel = 8
48 )
49
50 var (
51         LogLevel_name = map[uint32]string{
52                 0: "VPE_API_LOG_LEVEL_EMERG",
53                 1: "VPE_API_LOG_LEVEL_ALERT",
54                 2: "VPE_API_LOG_LEVEL_CRIT",
55                 3: "VPE_API_LOG_LEVEL_ERR",
56                 4: "VPE_API_LOG_LEVEL_WARNING",
57                 5: "VPE_API_LOG_LEVEL_NOTICE",
58                 6: "VPE_API_LOG_LEVEL_INFO",
59                 7: "VPE_API_LOG_LEVEL_DEBUG",
60                 8: "VPE_API_LOG_LEVEL_DISABLED",
61         }
62         LogLevel_value = map[string]uint32{
63                 "VPE_API_LOG_LEVEL_EMERG":    0,
64                 "VPE_API_LOG_LEVEL_ALERT":    1,
65                 "VPE_API_LOG_LEVEL_CRIT":     2,
66                 "VPE_API_LOG_LEVEL_ERR":      3,
67                 "VPE_API_LOG_LEVEL_WARNING":  4,
68                 "VPE_API_LOG_LEVEL_NOTICE":   5,
69                 "VPE_API_LOG_LEVEL_INFO":     6,
70                 "VPE_API_LOG_LEVEL_DEBUG":    7,
71                 "VPE_API_LOG_LEVEL_DISABLED": 8,
72         }
73 )
74
75 func (x LogLevel) String() string {
76         s, ok := LogLevel_name[uint32(x)]
77         if ok {
78                 return s
79         }
80         return "LogLevel(" + strconv.Itoa(int(x)) + ")"
81 }
82
83 // Timedelta defines alias 'timedelta'.
84 type Timedelta float64
85
86 // Timestamp defines alias 'timestamp'.
87 type Timestamp float64
88
89 func NewTimestamp(t time.Time) Timestamp {
90         sec := int64(t.Unix())
91         nsec := int32(t.Nanosecond())
92         ns := float64(sec) + float64(nsec/1e9)
93         return Timestamp(ns)
94 }
95
96 func (x Timestamp) ToTime() time.Time {
97         ns := int64(x * 1e9)
98         sec := ns / 1e9
99         nsec := ns % 1e9
100         return time.Unix(sec, nsec)
101 }
102
103 func (x Timestamp) String() string {
104         return x.ToTime().String()
105 }
106
107 func (x *Timestamp) MarshalText() ([]byte, error) {
108         return []byte(x.ToTime().Format(time.RFC3339Nano)), nil
109 }
110
111 func (x *Timestamp) UnmarshalText(text []byte) error {
112         t, err := time.Parse(time.RFC3339Nano, string(text))
113         if err != nil {
114                 return err
115         }
116         *x = NewTimestamp(t)
117         return nil
118 }
119
120 // Version defines type 'version'.
121 type Version struct {
122         Major         uint32 `binapi:"u32,name=major" json:"major,omitempty"`
123         Minor         uint32 `binapi:"u32,name=minor" json:"minor,omitempty"`
124         Patch         uint32 `binapi:"u32,name=patch" json:"patch,omitempty"`
125         PreRelease    []byte `binapi:"u8[17],name=pre_release" json:"pre_release,omitempty"`
126         BuildMetadata []byte `binapi:"u8[17],name=build_metadata" json:"build_metadata,omitempty"`
127 }