Skip to content
Effect Days 2026 Get your ticket

IpInterface

IPv4 and IPv6 interface addresses that preserve host bits alongside a prefix length.

14 exports Added in v4.0.0 Source

Constructors

make

Added in v4.0.0 Source

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

Added in v4.0.0 Source

Parses 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>

Parses 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>

Parses 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

format

Added in v4.0.0 Source

Formats an interface address using canonical address text and its decimal prefix length.

Signature

declare function format(self: IpInterface): string

Guards

Returns true when a value is an IP interface address.

Signature

declare function isIpInterface(u: unknown): u is IpInterface<IpAddress>

Returns true when a value is an IPv4 interface address.

Signature

declare function isIpv4Interface(u: unknown): u is Ipv4Interface

Returns true when a value is an IPv6 interface address.

Signature

declare function isIpv6Interface(u: unknown): u is Ipv6Interface

Models

IpInterface interface

Added in v4.0.0 Source

An IP host address and prefix length. Host bits are preserved.

Signature

interface IpInterface<out A extends NetAddress.IpAddress = NetAddress.IpAddress> extends Equal, Hash {
readonly _tag: "IpInterface";
readonly "~effect/net/IpInterface": "~effect/net/IpInterface";
readonly address: A;
readonly prefixLength: number;
toJSON(): string;
toString(): string;
}

Ipv4Interface type

Added in v4.0.0 Source

An IPv4 host address and prefix length.

Signature

type Ipv4Interface = IpInterface<NetAddress.Ipv4Address>

Ipv6Interface type

Added in v4.0.0 Source

An IPv6 host address and prefix length.

Signature

type Ipv6Interface = IpInterface<NetAddress.Ipv6Address>

Other

IpInterface

Added in v4.0.0 Source

Companion types for parsing IP interface addresses.

Unsafe

Parses a trusted interface address, throwing on failure.

Signature

declare function fromStringUnsafe(input: string, options?: ParseOptions): IpInterface

makeUnsafe

Added in v4.0.0 Source

Creates a trusted interface address, throwing when its prefix length is invalid.

Signature

declare function makeUnsafe<A extends IpAddress>(address: A, prefixLength: number): IpInterface<A>