summaryrefslogtreecommitdiffstats
path: root/binapi/vpe_types
diff options
context:
space:
mode:
authorAloys Augustin <aloaugus@cisco.com>2021-10-18 14:16:59 +0200
committerOndrej Fabry <ofabry@cisco.com>2021-11-29 07:16:05 +0000
commit0a0c03d459547aa9004cbbc1ed9a358d831adf03 (patch)
treee461f1100fa7e5faf6db331708f9cbbad4c0e829 /binapi/vpe_types
parent4cc53fc9a836df099dde983d506eb892dc2fdef1 (diff)
Add "FromIP" helper for addresses
Change-Id: Ib34b84b8267c95ce3bacef4806cc52a6c7c24f05 Signed-off-by: Aloys Augustin <aloaugus@cisco.com>
Diffstat (limited to 'binapi/vpe_types')
-rw-r--r--binapi/vpe_types/vpe_types.ba.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/binapi/vpe_types/vpe_types.ba.go b/binapi/vpe_types/vpe_types.ba.go
index 64e988f..779cbdb 100644
--- a/binapi/vpe_types/vpe_types.ba.go
+++ b/binapi/vpe_types/vpe_types.ba.go
@@ -86,18 +86,22 @@ func NewTimestamp(t time.Time) Timestamp {
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 {