X-Git-Url: https://gerrit.fd.io/r/gitweb?p=govpp.git;a=blobdiff_plain;f=internal%2Ftestbinapi%2Fbinapi2001%2Fvpe%2Fvpe.ba.go;fp=internal%2Ftestbinapi%2Fbinapi2001%2Fvpe%2Fvpe.ba.go;h=34842fb1847704ef617a6868299942af5887ccce;hp=f970104364a98b664af219f5f6fad384ceb4fd59;hb=4102c72bce694babd94a481b1201d33895a6f9c5;hpb=a4112fac7b86fe09650d2bb57969fe46404edd7d diff --git a/internal/testbinapi/binapi2001/vpe/vpe.ba.go b/internal/testbinapi/binapi2001/vpe/vpe.ba.go index f970104..34842fb 100644 --- a/internal/testbinapi/binapi2001/vpe/vpe.ba.go +++ b/internal/testbinapi/binapi2001/vpe/vpe.ba.go @@ -1,6 +1,6 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-dev +// binapi-generator: v0.5.0-dev // VPP: 20.01 // source: .vppapi/core/vpe.api.json @@ -15,9 +15,11 @@ package vpe import ( + "strconv" + "time" + api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" - "strconv" ) // This is a compile-time assertion to ensure that this generated file @@ -86,6 +88,37 @@ type Timedelta float64 // Timestamp defines alias 'timestamp'. type Timestamp float64 +func NewTimestamp(t time.Time) Timestamp { + sec := int64(t.Unix()) + nsec := int32(t.Nanosecond()) + ns := float64(sec) + float64(nsec/1e9) + return Timestamp(ns) +} + +func (x Timestamp) ToTime() time.Time { + ns := int64(x * 1e9) + sec := ns / 1e9 + nsec := ns % 1e9 + return time.Unix(sec, nsec) +} + +func (x Timestamp) String() string { + return x.ToTime().String() +} + +func (x *Timestamp) MarshalText() ([]byte, error) { + return []byte(x.ToTime().Format(time.RFC3339Nano)), nil +} + +func (x *Timestamp) UnmarshalText(text []byte) error { + t, err := time.Parse(time.RFC3339Nano, string(text)) + if err != nil { + return err + } + *x = NewTimestamp(t) + return nil +} + // ThreadData defines type 'thread_data'. type ThreadData struct { ID uint32 `binapi:"u32,name=id" json:"id,omitempty"`