github.com/edwarnicke/govpp@v0.0.0-20230130211138-14ef5d20b1d0/binapi/vpe_types/vpe_types.ba.go (about)

     1  // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
     2  // versions:
     3  //  binapi-generator: v0.4.0-dev
     4  //  VPP:              23.02-rc0~189-g57127b32a
     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  // LogLevel defines enum 'log_level'.
    30  type LogLevel uint32
    31  
    32  const (
    33  	VPE_API_LOG_LEVEL_EMERG    LogLevel = 0
    34  	VPE_API_LOG_LEVEL_ALERT    LogLevel = 1
    35  	VPE_API_LOG_LEVEL_CRIT     LogLevel = 2
    36  	VPE_API_LOG_LEVEL_ERR      LogLevel = 3
    37  	VPE_API_LOG_LEVEL_WARNING  LogLevel = 4
    38  	VPE_API_LOG_LEVEL_NOTICE   LogLevel = 5
    39  	VPE_API_LOG_LEVEL_INFO     LogLevel = 6
    40  	VPE_API_LOG_LEVEL_DEBUG    LogLevel = 7
    41  	VPE_API_LOG_LEVEL_DISABLED LogLevel = 8
    42  )
    43  
    44  var (
    45  	LogLevel_name = map[uint32]string{
    46  		0: "VPE_API_LOG_LEVEL_EMERG",
    47  		1: "VPE_API_LOG_LEVEL_ALERT",
    48  		2: "VPE_API_LOG_LEVEL_CRIT",
    49  		3: "VPE_API_LOG_LEVEL_ERR",
    50  		4: "VPE_API_LOG_LEVEL_WARNING",
    51  		5: "VPE_API_LOG_LEVEL_NOTICE",
    52  		6: "VPE_API_LOG_LEVEL_INFO",
    53  		7: "VPE_API_LOG_LEVEL_DEBUG",
    54  		8: "VPE_API_LOG_LEVEL_DISABLED",
    55  	}
    56  	LogLevel_value = map[string]uint32{
    57  		"VPE_API_LOG_LEVEL_EMERG":    0,
    58  		"VPE_API_LOG_LEVEL_ALERT":    1,
    59  		"VPE_API_LOG_LEVEL_CRIT":     2,
    60  		"VPE_API_LOG_LEVEL_ERR":      3,
    61  		"VPE_API_LOG_LEVEL_WARNING":  4,
    62  		"VPE_API_LOG_LEVEL_NOTICE":   5,
    63  		"VPE_API_LOG_LEVEL_INFO":     6,
    64  		"VPE_API_LOG_LEVEL_DEBUG":    7,
    65  		"VPE_API_LOG_LEVEL_DISABLED": 8,
    66  	}
    67  )
    68  
    69  func (x LogLevel) String() string {
    70  	s, ok := LogLevel_name[uint32(x)]
    71  	if ok {
    72  		return s
    73  	}
    74  	return "LogLevel(" + strconv.Itoa(int(x)) + ")"
    75  }
    76  
    77  // Timedelta defines alias 'timedelta'.
    78  type Timedelta float64
    79  
    80  // Timestamp defines alias 'timestamp'.
    81  type Timestamp float64
    82  
    83  func NewTimestamp(t time.Time) Timestamp {
    84  	sec := int64(t.Unix())
    85  	nsec := int32(t.Nanosecond())
    86  	ns := float64(sec) + float64(nsec/1e9)
    87  	return Timestamp(ns)
    88  }
    89  func (x Timestamp) ToTime() time.Time {
    90  	ns := int64(x * 1e9)
    91  	sec := ns / 1e9
    92  	nsec := ns % 1e9
    93  	return time.Unix(sec, nsec)
    94  }
    95  func (x Timestamp) String() string {
    96  	return x.ToTime().String()
    97  }
    98  func (x *Timestamp) MarshalText() ([]byte, error) {
    99  	return []byte(x.ToTime().Format(time.RFC3339Nano)), nil
   100  }
   101  func (x *Timestamp) UnmarshalText(text []byte) error {
   102  	t, err := time.Parse(time.RFC3339Nano, string(text))
   103  	if err != nil {
   104  		return err
   105  	}
   106  	*x = NewTimestamp(t)
   107  	return nil
   108  }
   109  
   110  // Version defines type 'version'.
   111  type Version struct {
   112  	Major         uint32 `binapi:"u32,name=major" json:"major,omitempty"`
   113  	Minor         uint32 `binapi:"u32,name=minor" json:"minor,omitempty"`
   114  	Patch         uint32 `binapi:"u32,name=patch" json:"patch,omitempty"`
   115  	PreRelease    []byte `binapi:"u8[17],name=pre_release" json:"pre_release,omitempty"`
   116  	BuildMetadata []byte `binapi:"u8[17],name=build_metadata" json:"build_metadata,omitempty"`
   117  }