diff --git a/types.go b/types.go index 2af1f65..4cd56d4 100644 --- a/types.go +++ b/types.go @@ -4,6 +4,7 @@ package metalbond import ( + "encoding/json" "fmt" "net/netip" @@ -23,6 +24,16 @@ type Destination struct { Prefix netip.Prefix } +func (d Destination) MarshalText() (text []byte, err error) { + type x Destination + return json.Marshal(x(d)) +} + +func (d *Destination) UnmarshalText(text []byte) error { + type x Destination + return json.Unmarshal(text, (*x)(d)) +} + func (d Destination) String() string { return d.Prefix.String() }