net
ModuleNetwork helpers: inet_pton/inet_ntop.
PHP's address functions call the C library; the dev image is Alpine, so
these are ports of musl's inet_pton/inet_ntop (src/network/), whose
IPv6 formatting differs from glibc's in which zero run it compresses.
Every function here is checked against the real PHP function by
bin/compat fuzz php-std (operations net.*).
Contents
use php_std::net::NulByteError;pub struct NulByteErrorPHP's ValueError for a string argument that must not contain NUL bytes
(Z_PARAM_PATH): "<function>(): Argument #1 ($ip) must not contain any null bytes".
Display.use php_std::net::PackedAddr;pub enum PackedAddrA packed address from inet_pton.
use php_std::net::inet_ntop;pub fn inet_ntop(packed: &[u8]) -> Option<String>PHP inet_ntop($ip): a 4-byte (IPv4) or 16-byte (IPv6) packed address
in text form; None (PHP's false) for any other length.
use php_std::net::inet_pton;pub fn inet_pton(ip: &[u8]) -> Result<Option<PackedAddr>, NulByteError>PHP inet_pton($ip): IPv6 when the string contains :, IPv4 when it
contains ., None (PHP's false) otherwise or when invalid.