IpInterface unstable
IPv4 and IPv6 interface addresses that preserve host bits alongside a prefix length.
Constructors
Converts an IpInterfaceInput to an interface address, parsing strings like
fromString with the given options, converting parts like make, and
returning interface addresses unchanged.
Signature
declare function fromInput(input: IpInterfaceInput, options?: ParseOptions): Result<IpInterface<IpAddress>, NetAddressError>ipv4FromInput
unstableConverts an Ipv4InterfaceInput to an IPv4 interface address, parsing
strings like ipv4FromString with the given options, converting parts like
make, and returning interface addresses unchanged.
Signature
declare function ipv4FromInput(input: Ipv4InterfaceInput, options?: ParseOptions): Result<Ipv4Interface, NetAddressError>ipv6FromInput
unstableConverts an Ipv6InterfaceInput to an IPv6 interface address, parsing
strings like ipv6FromString with the given options, converting parts like
make, and returning interface addresses unchanged.
Signature
declare function ipv6FromInput(input: Ipv6InterfaceInput, options?: ParseOptions): Result<Ipv6Interface, NetAddressError>Creates an interface address while preserving all address bits.
Signature
declare function make<A extends IpAddress>(address: A, prefixLength: number): Result<IpInterface<A>, NetAddressError>Decoding
fromString
unstableParses an IP interface address while preserving host bits.
Details
A missing prefix defaults to the address width. Use prefix: "required" to
require one.
Signature
declare function fromString(input: string, options?: ParseOptions): Result<IpInterface<IpAddress>, NetAddressError>ipv4FromString
unstableParses an IPv4 interface address while preserving host bits.
Details
A missing prefix defaults to 32. Use prefix: "required" to require one.
Signature
declare function ipv4FromString(input: string, options?: ParseOptions): Result<Ipv4Interface, NetAddressError>ipv6FromString
unstableParses an IPv6 interface address while preserving host bits.
Details
A missing prefix defaults to 128. Use prefix: "required" to require one.
Signature
declare function ipv6FromString(input: string, options?: ParseOptions): Result<Ipv6Interface, NetAddressError>Encoding
Guards
isIpInterface
unstableReturns true when a value is an IP interface address.
Signature
declare function isIpInterface(u: unknown): u is IpInterface<IpAddress>isIpv4Interface
unstableReturns true when a value is an IPv4 interface address.
Signature
declare function isIpv4Interface(u: unknown): u is Ipv4InterfaceisIpv6Interface
unstableReturns true when a value is an IPv6 interface address.
Signature
declare function isIpv6Interface(u: unknown): u is Ipv6InterfaceModels
An IP host address and prefix length. Host bits and any verified address refinements are preserved because the address is retained unchanged. Code that computes different address bits must widen to the IPv4 or IPv6 family, or validate the resulting address before treating it as refined.
Signature
interface IpInterface<out A extends NetAddress.IpAddress = NetAddress.IpAddress> extends Equal, Hash, Inspectable { readonly _tag: "IpInterface"; readonly "~effect/net/IpInterface": "~effect/net/IpInterface"; readonly address: A; readonly prefixLength: number;}An interface address, or a string or parts to convert to one.
Signature
type IpInterfaceInput = IpInterface | string | IpInterfacePartsAn address and prefix length, generic over the accepted address input.
See
- make for the checked constructor
Signature
interface IpInterfaceParts<A extends NetAddress.IpAddressInput = NetAddress.IpAddressInput> { readonly address: A; readonly prefixLength: number;}An IPv4 host address and prefix length.
Signature
type Ipv4Interface = IpInterface<NetAddress.Ipv4Address>An IPv4 interface address, or a string or parts to convert to one.
Signature
type Ipv4InterfaceInput = Ipv4Interface | string | IpInterfaceParts<NetAddress.Ipv4AddressInput>An IPv6 host address and prefix length.
Signature
type Ipv6Interface = IpInterface<NetAddress.Ipv6Address>An IPv6 interface address, or a string or parts to convert to one.
Signature
type Ipv6InterfaceInput = Ipv6Interface | string | IpInterfaceParts<NetAddress.Ipv6AddressInput>Other
IpInterface
unstableCompanion types for parsing IP interface addresses.
Unsafe
fromInputUnsafe
unstableConverts a trusted IpInterfaceInput to an interface address, throwing on failure.
Signature
declare function fromInputUnsafe(input: IpInterfaceInput, options?: ParseOptions): IpInterfacefromStringUnsafe
unstableParses a trusted interface address, throwing on failure.
Signature
declare function fromStringUnsafe(input: string, options?: ParseOptions): IpInterfacemakeUnsafe
unstableCreates a trusted interface address, throwing when its prefix length is invalid.
Signature
declare function makeUnsafe<A extends IpAddress>(address: A, prefixLength: number): IpInterface<A>