Skip to content

Commit

Permalink
add marshaler methods for Destination struct
Browse files Browse the repository at this point in the history
  • Loading branch information
vlorinc committed Jan 8, 2024
1 parent 34a4177 commit 52b9fa4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package metalbond

import (
"encoding/json"
"fmt"

"net/netip"
Expand All @@ -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()
}
Expand Down

0 comments on commit 52b9fa4

Please sign in to comment.