API
#net/netip
Xu 0.8.8 API
import: #net/netip
counts: 5 fns, 17 methods, 3 types, 0 consts, 0 ifaces
Addr / AddrPort / Prefix: owning 4- or 16-byte addresses.
struct Addr
pub struct Addr {
pub ip string
pub zone string
}
Purpose
netip — `net/netip` subset. Addr is a parsed IP (raw bytes + zone). No allocation-heavy net.IP slice; the owning string is 4 or 16 bytes.
Parameters
ip string- field (string)
zone string- field (string)
struct AddrPort
pub struct AddrPort {
pub addr Addr
pub port int
}
Purpose
Public struct `AddrPort`.
Parameters
addr Addr- address
port int- port
struct Prefix
pub struct Prefix {
pub addr Addr
pub bits int
}
Purpose
Public struct `Prefix`.
Parameters
addr Addr- address
bits int- bit count
addr_from4
pub fn addr_from4(a int, b int, c int, d int) Addr
Purpose
Address from4.
Parameters
a int- value (int)
b int- b (int)
c int- byte or character code (int)
d int- d (int)
Returns
Addr — a value of this type
addr_from16
pub fn addr_from16(ip string) Addr
Purpose
Address from16. Throws on failure.
Parameters
ip string- ip (string)
Returns
Addr — a value of this type
parse_addr
pub fn parse_addr(s string) Addr
Purpose
Parse as addr. Throws on failure.
Parameters
s string- source string (string)
Returns
Addr — a value of this type
(Addr) is_valid
pub fn (a Addr) is_valid() bool
Purpose
Method on `Addr`: whether it is valid.
Parameters
a Addr- receiver Addr (value receiver)
Returns
bool — true or false
(Addr) is4
pub fn (a Addr) is4() bool
Purpose
Call `is4` on `Addr`.
Parameters
a Addr- receiver Addr (value receiver)
Returns
bool — true or false
(Addr) is6
pub fn (a Addr) is6() bool
Purpose
Call `is6` on `Addr`.
Parameters
a Addr- receiver Addr (value receiver)
Returns
bool — true or false
(Addr) is4_in6
pub fn (a Addr) is4_in6() bool
Purpose
Method on `Addr`: is4 in6.
Parameters
a Addr- receiver Addr (value receiver)
Returns
bool — true or false
(Addr) unmap
pub fn (a Addr) unmap() Addr
Purpose
Call `unmap` on `Addr`.
Parameters
a Addr- receiver Addr (value receiver)
Returns
Addr — a value of this type
(Addr) with_zone
pub fn (a Addr) with_zone(zone string) Addr
Purpose
Method on `Addr`: derive a new value with zone.
Parameters
a Addr- receiver Addr (value receiver)
zone string- zone (string)
Returns
Addr — a value of this type
(Addr) to_string
pub fn (a Addr) to_string() string
Purpose
Method on `Addr`: convert to string.
Parameters
a Addr- receiver Addr (value receiver)
Returns
string — result string
(Addr) is_unspecified
pub fn (a Addr) is_unspecified() bool
Purpose
Method on `Addr`: whether it is unspecified.
Parameters
a Addr- receiver Addr (value receiver)
Returns
bool — true or false
(Addr) is_loopback
pub fn (a Addr) is_loopback() bool
Purpose
Method on `Addr`: whether it is loopback.
Parameters
a Addr- receiver Addr (value receiver)
Returns
bool — true or false
(Addr) is_private
pub fn (a Addr) is_private() bool
Purpose
Method on `Addr`: whether it is private.
Parameters
a Addr- receiver Addr (value receiver)
Returns
bool — true or false
(Addr) is_multicast
pub fn (a Addr) is_multicast() bool
Purpose
Method on `Addr`: whether it is multicast.
Parameters
a Addr- receiver Addr (value receiver)
Returns
bool — true or false
(Addr) is_global_unicast
pub fn (a Addr) is_global_unicast() bool
Purpose
Method on `Addr`: whether it is global unicast.
Parameters
a Addr- receiver Addr (value receiver)
Returns
bool — true or false
(Addr) is_link_local_unicast
pub fn (a Addr) is_link_local_unicast() bool
Purpose
Method on `Addr`: whether it is link local unicast.
Parameters
a Addr- receiver Addr (value receiver)
Returns
bool — true or false
parse_addr_port
pub fn parse_addr_port(s string) AddrPort
Purpose
Parse as addr port. Throws on failure.
Parameters
s string- source string (string)
Returns
AddrPort — a value of this type
(AddrPort) to_string
pub fn (ap AddrPort) to_string() string
Purpose
Method on `AddrPort`: convert to string.
Parameters
ap AddrPort- receiver AddrPort (value receiver)
Returns
string — result string
(AddrPort) is_valid
pub fn (ap AddrPort) is_valid() bool
Purpose
Method on `AddrPort`: whether it is valid.
Parameters
ap AddrPort- receiver AddrPort (value receiver)
Returns
bool — true or false
parse_prefix
pub fn parse_prefix(s string) Prefix
Purpose
Parse as prefix. Throws on failure.
Parameters
s string- source string (string)
Returns
Prefix — a value of this type
(Prefix) to_string
pub fn (p Prefix) to_string() string
Purpose
Method on `Prefix`: convert to string.
Parameters
p Prefix- receiver Prefix (value receiver)
Returns
string — result string
(Prefix) contains
pub fn (p Prefix) contains(a Addr) bool
Purpose
Method on `Prefix`: report whether the input contains the given piece.
Parameters
p Prefix- receiver Prefix (value receiver)
a Addr- value (Addr)
Returns
bool — true or false