silk/network_address
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc.
Owned network addresses, endpoints, and validated origin hosts.
When to use
Parse URI hosts before resolution, retain the resulting Host for HTTP/TLS identity, and pass its numeric address or domain to silk.resolver.
Details
IPv4 and IPv6 own network-order octets. DomainHost owns its admitted source spelling in fixed 253-byte storage and compares ASCII case-insensitively. Parsing and formatting allocate nothing.
Gotchas
This profile accepts prepared ASCII LDH/A-label domains only. It rejects search-root dots, Unicode mapping, escapes, zones, IPvFuture, userinfo, ports, and legacy libc IPv4 spellings.
Import as NetworkAddress with import silk.network_address { NetworkAddress }.
Public declarations: 12.
AddressReason
pub enum AddressReasonThe failed network-address admission rule.
Empty
Empty = 0The numeric address input is empty.
InvalidCharacter
InvalidCharacter = 1An input byte is not admitted in this position.
InvalidComponent
InvalidComponent = 2An address component has invalid syntax.
LeadingZero
LeadingZero = 3An IPv4 component contains a prohibited leading zero.
ComponentOverflow
ComponentOverflow = 4An address component exceeds its numeric range.
WrongComponentCount
WrongComponentCount = 5The address has the wrong number of components.
MultipleCompression
MultipleCompression = 6The IPv6 spelling contains multiple compression markers.
CompressionWithoutOmission
CompressionWithoutOmission = 7IPv6 compression does not omit any component.
HostReason
pub enum HostReasonThe failed domain-host admission rule.
EmptyName
EmptyName = 0The domain name is empty.
NameTooLong
NameTooLong = 1The domain name exceeds the admitted byte length.
EmptyLabel
EmptyLabel = 2A domain label is empty.
LabelTooLong
LabelTooLong = 3A domain label exceeds the admitted byte length.
Nul
Nul = 4The domain contains a NUL byte.
NonAscii
NonAscii = 5The domain contains a non-ASCII byte.
InvalidCharacter
InvalidCharacter = 6An input byte is not admitted in this position.
EdgeHyphen
EdgeHyphen = 7A domain label begins or ends with a hyphen.
InvalidALabel
InvalidALabel = 8An encoded internationalized label is invalid.
TrailingDot
TrailingDot = 9The domain has a prohibited trailing dot.
NumericFinalLabel
NumericFinalLabel = 10The final domain label is entirely numeric.
UnsupportedHostForm
pub enum UnsupportedHostFormA URI host form outside the first network profile.
IpvFuture
IpvFuture = 0The host uses unsupported IPvFuture syntax.
ZoneIdentifier
ZoneIdentifier = 1The host contains an unsupported IPv6 zone identifier.
EscapedHost
EscapedHost = 2The host contains unsupported percent escapes.
UserInfo
UserInfo = 3The host input contains URI user information.
PortDelimiter
PortDelimiter = 4The host input contains a port delimiter.
UriDelimiter
UriDelimiter = 5The host input contains a URI delimiter.
AddressError
pub union AddressErrorA typed value-construction or presentation failure.
InvalidAddress
AddressError.InvalidAddress { reason: AddressReason, offset: usize }: AddressErrorNumeric address admission failed.
Field reason
pub reason: AddressReasonThe admission rule that rejected the supplied bytes.
Field offset
pub offset: usizeThe zero-based byte offset of the rejected input.
InvalidHost
AddressError.InvalidHost { reason: HostReason, offset: usize }: AddressErrorDomain host admission failed.
Field reason
pub reason: HostReasonThe admission rule that rejected the supplied bytes.
Field offset
pub offset: usizeThe zero-based byte offset of the rejected input.
InvalidPort
AddressError.InvalidPort { value: usize }: AddressErrorThe supplied port is outside 0..65535.
Field value
pub value: usizeThe supplied port number outside the admitted 0..65535 range.
UnsupportedForm
AddressError.UnsupportedForm { form: UnsupportedHostForm, offset: usize }: AddressErrorThe input uses an unsupported host form.
Field form
pub form: UnsupportedHostFormThe unsupported URI host form.
Field offset
pub offset: usizeThe zero-based byte offset of the rejected input.
OutputTooSmall
AddressError.OutputTooSmall { required: usize, available: usize }: AddressErrorThe supplied output cannot hold the complete formatted value.
Field required
pub required: usizeThe output capacity needed for the complete spelling.
Field available
pub available: usizeThe output capacity supplied by the caller.
Ipv4Address
pub struct Ipv4AddressFour owned network-order IPv4 octets.
Associated function Ipv4Address.fromOctets
pub fn fromOctets(octets: Array<u8, 4>) -> Ipv4AddressConstructs an IPv4 address from exact network-order octets.
Associated function Ipv4Address.parse
pub fn parse<'life0>(bytes: &'life0 [u8]) -> silk/result.Result<silk/network_address.Ipv4Address, silk/network_address.AddressError>Parses a strict RFC 3986 decimal dotted quad.
Method Ipv4Address.octets
pub fn octets<'life0>(self: &'life0 Ipv4Address) -> Array<u8, 4>Returns the owned network-order octets by value.
Method Ipv4Address.equals
pub fn equals<'life0, 'life1>(self: &'life0 Ipv4Address, other: &'life1 Ipv4Address) -> boolReports exact binary equality.
Method Ipv4Address.formatInto
pub fn formatInto<'life0, 'life1>(self: &'life0 Ipv4Address, output: &'life1 mut [u8]) -> silk/result.Result<usize, silk/network_address.AddressError>Formats canonical decimal dotted-quad text without partial output.
Ipv6Address
pub struct Ipv6AddressSixteen owned network-order IPv6 octets.
Associated function Ipv6Address.fromOctets
pub fn fromOctets(octets: Array<u8, 16>) -> Ipv6AddressConstructs an IPv6 address from exact network-order octets.
Associated function Ipv6Address.parse
pub fn parse<'life0>(bytes: &'life0 [u8]) -> silk/result.Result<silk/network_address.Ipv6Address, silk/network_address.AddressError>Parses RFC 4291 IPv6 text without zones or IPvFuture.
Method Ipv6Address.octets
pub fn octets<'life0>(self: &'life0 Ipv6Address) -> Array<u8, 16>Returns the owned network-order octets by value.
Method Ipv6Address.equals
pub fn equals<'life0, 'life1>(self: &'life0 Ipv6Address, other: &'life1 Ipv6Address) -> boolReports exact binary equality.
Method Ipv6Address.formatInto
pub fn formatInto<'life0, 'life1>(self: &'life0 Ipv6Address, output: &'life1 mut [u8]) -> silk/result.Result<usize, silk/network_address.AddressError>Formats canonical RFC 5952 lowercase text without partial output.
IpAddress
pub union IpAddressAn owned numeric network address whose family remains explicit.
V4
IpAddress.V4 { value: Ipv4Address }: IpAddressAn IPv4 address.
Field value
pub value: Ipv4AddressThe four network-order IPv4 octets.
V6
IpAddress.V6 { value: Ipv6Address }: IpAddressAn IPv6 address.
Field value
pub value: Ipv6AddressThe sixteen network-order IPv6 octets.
Method IpAddress.isV4
pub fn isV4<'life0>(self: &'life0 IpAddress) -> boolReports whether this address is IPv4.
Method IpAddress.equals
pub fn equals<'life0, 'life1>(self: &'life0 IpAddress, other: &'life1 IpAddress) -> boolReports family-sensitive exact equality.
Method IpAddress.formatInto
pub fn formatInto<'life0, 'life1>(self: &'life0 IpAddress, output: &'life1 mut [u8]) -> silk/result.Result<usize, silk/network_address.AddressError>Formats the selected canonical address form.
Port
pub struct PortA checked transport port. Zero is valid for listener binding.
Associated function Port.make
pub fn make(value: usize) -> silk/result.Result<silk/network_address.Port, silk/network_address.AddressError>Checks a pointer-width integer as an inclusive u16 transport port.
Associated function Port.fromU16
pub fn fromU16(value: u16) -> PortConstructs a port from an already checked u16.
Method Port.value
pub fn value<'life0>(self: &'life0 Port) -> u16Returns the underlying checked u16.
Endpoint
pub struct EndpointAn owned connectable numeric address and port.
Associated function Endpoint.make
pub fn make(address: IpAddress, port: Port) -> EndpointOwns one numeric address and checked port.
Method Endpoint.address
pub fn address<'life0>(self: &'life0 Endpoint) -> IpAddressReturns the owned address by value.
Method Endpoint.port
pub fn port<'life0>(self: &'life0 Endpoint) -> PortReturns the checked port by value.
Method Endpoint.equals
pub fn equals<'life0, 'life1>(self: &'life0 Endpoint, other: &'life1 Endpoint) -> boolReports exact address-and-port equality.
DomainHost
pub struct DomainHostA validated absolute ASCII domain in preserved source spelling.
Associated function DomainHost.make
pub fn make<'life0>(bytes: &'life0 [u8]) -> silk/result.Result<silk/network_address.DomainHost, silk/network_address.AddressError>Copies and validates an absolute unrooted ASCII LDH/A-label domain.
Method DomainHost.bytes
pub fn bytes<'a>(self: &'a DomainHost) -> &'a [u8]Borrows the preserved source-spelling bytes.
Method DomainHost.length
pub fn length<'life0>(self: &'life0 DomainHost) -> usizeReturns the stored byte length.
Method DomainHost.equals
pub fn equals<'life0, 'life1>(self: &'life0 DomainHost, other: &'life1 DomainHost) -> boolReports ASCII case-insensitive equality.
Host
pub union HostA classified owned origin host.
Domain
Host.Domain { value: DomainHost }: HostA validated ASCII domain host.
Field value
pub value: DomainHostThe validated ASCII domain in its original spelling.
Ipv4
Host.Ipv4 { value: Ipv4Address }: HostAn owned IPv4 origin host.
Field value
pub value: Ipv4AddressThe four network-order IPv4 octets.
Ipv6
Host.Ipv6 { value: Ipv6Address }: HostAn owned IPv6 origin host.
Field value
pub value: Ipv6AddressThe sixteen network-order IPv6 octets.
Associated function Host.parse
pub fn parse<'life0>(bytes: &'life0 [u8]) -> silk/result.Result<silk/network_address.Host, silk/network_address.AddressError>Classifies an RFC 3986 URI host into owned numeric or domain identity.
Method Host.numeric
pub fn numeric<'life0>(self: &'life0 Host) -> () | silk/network_address.IpAddressReturns the numeric address when this host is numeric.
NetworkAddress
pub struct NetworkAddressOperations shared across the network address value family.
Implementation Copy for AddressError
impl Copy for AddressErrorImplementation Copy for Ipv4Address
impl Copy for Ipv4AddressImplementation Copy for Ipv6Address
impl Copy for Ipv6AddressImplementation Copy for IpAddress
impl Copy for IpAddressImplementation Copy for Port
impl Copy for PortImplementation Copy for Endpoint
impl Copy for EndpointImplementation Copy for DomainHost
impl Copy for DomainHostImplementation Copy for Host
impl Copy for HostImplementation Display for Ipv4Address
impl Display for Ipv4AddressOperation display
display = Ipv4Address.impl@9.displayImplementation Display for Ipv6Address
impl Display for Ipv6AddressOperation display
display = Ipv6Address.impl@10.displayImplementation Display for IpAddress
impl Display for IpAddressOperation display
display = IpAddress.impl@11.displayImplementation Display for DomainHost
impl Display for DomainHostOperation display
display = DomainHost.impl@12.display