peer_addr_docgen.go
// Code generated by nimona.io. DO NOT EDIT.
package nimona
import (
"github.com/vikyd/zero"
"nimona.io/tilde"
)
var _ = zero.IsZeroVal
var _ = tilde.NewScanner
func (t *PeerAddr) Document() *Document {
return NewDocument(t.Map())
}
func (t *PeerAddr) Map() tilde.Map {
m := tilde.Map{}
// # t.$type
//
// Type: string, Kind: string, TildeKind: InvalidValueKind0
// IsSlice: false, IsStruct: false, IsPointer: false
{
m.Set("$type", tilde.String("core/node.address"))
}
// # t.Address
//
// Type: string, Kind: string, TildeKind: String
// IsSlice: false, IsStruct: false, IsPointer: false
{
if !zero.IsZeroVal(t.Address) {
m.Set("address", tilde.String(t.Address))
}
}
// # t.PublicKey
//
// Type: nimona.PublicKey, Kind: slice, TildeKind: Bytes
// IsSlice: true, IsStruct: false, IsPointer: false
//
// ElemType: uint8, ElemKind: uint8
// IsElemSlice: false, IsElemStruct: false, IsElemPointer: false
{
if !zero.IsZeroVal(t.PublicKey) {
m.Set("publicKey", tilde.Bytes(t.PublicKey))
}
}
// # t.Transport
//
// Type: string, Kind: string, TildeKind: String
// IsSlice: false, IsStruct: false, IsPointer: false
{
if !zero.IsZeroVal(t.Transport) {
m.Set("transport", tilde.String(t.Transport))
}
}
return m
}
func (t *PeerAddr) FromDocument(d *Document) error {
return t.FromMap(d.Map())
}
func (t *PeerAddr) FromMap(d tilde.Map) error {
*t = PeerAddr{}
// # t.Address
//
// Type: string, Kind: string, TildeKind: String
// IsSlice: false, IsStruct: false, IsPointer: false
{
if v, err := d.Get("address"); err == nil {
if v, ok := v.(tilde.String); ok {
t.Address = string(v)
}
}
}
// # t.PublicKey
//
// Type: nimona.PublicKey, Kind: slice, TildeKind: Bytes
// IsSlice: true, IsStruct: false, IsPointer: false
//
// ElemType: uint8, ElemKind: uint8, ElemTildeKind: InvalidValueKind0
// IsElemSlice: false, IsElemStruct: false, IsElemPointer: false
{
if v, err := d.Get("publicKey"); err == nil {
if v, ok := v.(tilde.Bytes); ok {
t.PublicKey = PublicKey(v)
}
}
}
// # t.Transport
//
// Type: string, Kind: string, TildeKind: String
// IsSlice: false, IsStruct: false, IsPointer: false
{
if v, err := d.Get("transport"); err == nil {
if v, ok := v.(tilde.String); ok {
t.Transport = string(v)
}
}
}
return nil
}