net-address 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,395 +1,847 @@
1
- import { IOption, IResult } from "@luolapeikko/result-option";
2
-
1
+ import { CoreResult } from "core-result";
3
2
  //#region src/Ipv6Addr.d.ts
4
3
  /**
5
- * Represents an IPv6 address.
6
- * @example
7
- * const addr1 = Ipv6Addr.from('2001:db8::1').unwrap();
8
- * const addr2 = new Ipv6Addr([0x2001, 0xdb8, 0, 0, 0, 0, 0, 1]);
9
- * const addr3 = new Ipv6Addr(0x20010db8000000000000000000000001n);
10
- * @since v0.0.1
11
- */
12
- declare class Ipv6Addr {
4
+ * Represents an IPv6 address.
5
+ * @example
6
+ * const addrRes1 = Ipv6Addr.from('2001:db8::1');
7
+ * const addr1 = Ipv6Addr.fromOrThrow('2001:db8::1');
8
+ * const addr2 = new Ipv6Addr([0x2001, 0xdb8, 0, 0, 0, 0, 0, 1]);
9
+ * const addr3 = new Ipv6Addr(0x20010db8000000000000000000000001n);
10
+ * @since v0.0.1
11
+ */
12
+ export declare class Ipv6Addr {
13
13
  #private;
14
- private static regex;
15
- /**
16
- * Creates an IPv6 address from text.
17
- * @returns A successful result with an IPv6 address, or an error when the input is invalid.
18
- * @example
19
- * const addr = Ipv6Addr.from('2001:db8::1').unwrap();
20
- * @since v0.0.1
21
- */
22
- static from(value: string): IResult<Ipv6Addr, TypeError | RangeError>;
23
- /**
24
- * Creates an IPv6 address from a 16-byte buffer.
25
- * @returns A successful result with an IPv6 address, or an error when the buffer cannot be read.
26
- * @since v0.0.1
27
- */
28
- static fromBuffer(buffer: ArrayBuffer, littleEndian?: boolean): IResult<Ipv6Addr>;
29
- /**
30
- * The number of bits in an IPv6 address.
31
- * @since v0.0.1
32
- */
14
+ /**
15
+ * Creates an IPv6 address from text.
16
+ * @returns A successful result with an IPv6 address, or an error when the input is invalid.
17
+ * @example
18
+ * const addrRes: CoreResult<Ipv6Addr, TypeError | RangeError> = Ipv6Addr.from('2001:db8::1');
19
+ * @since v0.0.1
20
+ */
21
+ static from(value: string): CoreResult<Ipv6Addr, TypeError | RangeError>;
22
+ /**
23
+ * Creates an IPv6 address from text and throws an error if the input is invalid.
24
+ * @param value The IPv6 address in string format.
25
+ * @returns The IPv6 address instance.
26
+ * @example
27
+ * const addr: Ipv6Addr = Ipv6Addr.fromOrThrow('2001:db8::1');
28
+ * @since v0.2.0
29
+ */
30
+ static fromOrThrow(value: string): Ipv6Addr;
31
+ /**
32
+ * Creates an IPv6 address from a 16-byte buffer.
33
+ * @returns A successful result with an IPv6 address, or an error when the buffer cannot be read.
34
+ * @example
35
+ * const addrRes: CoreResult<Ipv6Addr> = Ipv6Addr.fromBuffer(buffer);
36
+ * @since v0.0.1
37
+ */
38
+ static fromBuffer(buffer: ArrayBuffer, littleEndian?: boolean): CoreResult<Ipv6Addr>;
39
+ /**
40
+ * Creates an IPv6 address from a 16-byte buffer and throws an error if the buffer cannot be read.
41
+ * @param buffer The 16-byte buffer containing the IPv6 address.
42
+ * @param littleEndian Whether the buffer is in little-endian format. Defaults to false (big-endian).
43
+ * @returns The IPv6 address instance.
44
+ * @example
45
+ * const addr: Ipv6Addr = Ipv6Addr.fromBufferOrThrow(buffer);
46
+ * @since v0.2.0
47
+ */
48
+ static fromBufferOrThrow(buffer: ArrayBuffer, littleEndian?: boolean): Ipv6Addr;
49
+ /**
50
+ * Creates an IPv6 address from a raw bigint value.
51
+ * @param value The raw bigint value representing the IPv6 address.
52
+ * @returns The IPv6 address instance.
53
+ * @example
54
+ * const addr: Ipv6Addr = Ipv6Addr.fromRaw(0x20010db8000000000000000000000001n);
55
+ * @since v0.2.0
56
+ */
57
+ static fromRaw(value: bigint): Ipv6Addr;
58
+ /**
59
+ * The number of bits in an IPv6 address.
60
+ * @since v0.0.1
61
+ */
33
62
  static readonly BITS = 128;
34
63
  /**
35
- * The loopback address (`::1`).
36
- * @since v0.0.1
37
- */
64
+ * The loopback address (`::1`).
65
+ * @since v0.0.1
66
+ */
38
67
  static readonly LOCALHOST: Ipv6Addr;
39
68
  /**
40
- * The unspecified address (`::`).
41
- * @since v0.0.1
42
- */
69
+ * The unspecified address (`::`).
70
+ * @since v0.0.1
71
+ */
43
72
  static readonly UNSPECIFIED: Ipv6Addr;
44
73
  /**
45
- * The address family identifier for IPv6 addresses.
46
- * @since v0.0.1
47
- */
74
+ * The address family identifier for IPv6 addresses.
75
+ * @since v0.0.1
76
+ */
48
77
  readonly family = "ipv6";
49
78
  /**
50
- * Creates a new IPv6 address instance.
51
- * @param value - A bigint representing the IPv6 address or an array of 8 numbers representing the segments of the address.
52
- * @throws {RangeError} If the segments array does not have exactly 8 elements or if any segment is out of range.
53
- * @throws {TypeError} If the input is neither a bigint nor an array of 8 numbers.
54
- */
79
+ * Gets the raw {@link BigInt} representation of the {@link Ipv6Addr} address.
80
+ * @since v0.2.0
81
+ */
82
+ get value(): bigint;
83
+ /**
84
+ * Creates a new {@link Ipv6Addr} address instance.
85
+ * @param value - A bigint representing the IPv6 address or an array of 8 numbers representing the segments of the address.
86
+ * @throws {RangeError} If the segments array does not have exactly 8 elements or if any segment is out of range.
87
+ * @throws {TypeError} If the input is neither a bigint nor an array of 8 numbers.
88
+ */
55
89
  constructor(value: bigint);
56
90
  constructor(segments: [number, number, number, number, number, number, number, number]);
57
91
  /**
58
- * Checks whether this address is in the benchmarking range.
59
- * @see https://tools.ietf.org/html/rfc5180 and https://www.rfc-editor.org/errata_search.php?eid=1752
60
- * @returns `true` when the address is in `2001:2::/48`, otherwise `false`.
61
- * @since v0.0.1
62
- */
92
+ * Checks whether this address is in the benchmarking range.
93
+ * @see https://tools.ietf.org/html/rfc5180 and https://www.rfc-editor.org/errata_search.php?eid=1752
94
+ * @returns `true` when the address is in `2001:2::/48`, otherwise `false`.
95
+ * @since v0.0.1
96
+ */
63
97
  isBenchmarking(): boolean;
64
98
  /**
65
- * Checks whether this address is in a documentation-only range.
66
- * @see https://tools.ietf.org/html/rfc3849 and https://tools.ietf.org/html/rfc9637
67
- * @returns `true` for `2001:db8::/32` or `3fff::/20`, otherwise `false`.
68
- * @since v0.0.1
69
- */
99
+ * Checks whether this address is in a documentation-only range.
100
+ * @see https://tools.ietf.org/html/rfc3849 and https://tools.ietf.org/html/rfc9637
101
+ * @returns `true` for `2001:db8::/32` or `3fff::/20`, otherwise `false`.
102
+ * @since v0.0.1
103
+ */
70
104
  isDocumentation(): boolean;
71
105
  /**
72
- * Checks whether this address is the loopback address.
73
- * @see https://tools.ietf.org/html/rfc4291#section-2.5.3
74
- * @returns `true` when the address is `::1`, otherwise `false`.
75
- * @since v0.0.1
76
- */
106
+ * Checks whether this address is the loopback address.
107
+ * @see https://tools.ietf.org/html/rfc4291#section-2.5.3
108
+ * @returns `true` when the address is `::1`, otherwise `false`.
109
+ * @since v0.0.1
110
+ */
77
111
  isLoopback(): boolean;
78
112
  /**
79
- * Checks whether this address is the unspecified address.
80
- * @see https://tools.ietf.org/html/rfc4291
81
- * @returns `true` when the address is `::`, otherwise `false`.
82
- * @since v0.0.1
83
- */
113
+ * Checks whether this address is the unspecified address.
114
+ * @see https://tools.ietf.org/html/rfc4291
115
+ * @returns `true` when the address is `::`, otherwise `false`.
116
+ * @since v0.0.1
117
+ */
84
118
  isUnspecified(): boolean;
85
119
  /**
86
- * Checks whether this address is a multicast address.
87
- * @see https://tools.ietf.org/html/rfc4291
88
- * @returns `true` when the address is in `ff00::/8`, otherwise `false`.
89
- * @since v0.0.1
90
- */
120
+ * Checks whether this address is a multicast address.
121
+ * @see https://tools.ietf.org/html/rfc4291
122
+ * @returns `true` when the address is in `ff00::/8`, otherwise `false`.
123
+ * @since v0.0.1
124
+ */
91
125
  isMulticast(): boolean;
92
126
  /**
93
- * Checks whether this address is a multicast interface-local address.
94
- * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
95
- * @returns `true` when the address is in `ff01::/16`, otherwise `false`.
96
- * @since v0.0.2
97
- */
127
+ * Checks whether this address is a multicast interface-local address.
128
+ * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
129
+ * @returns `true` when the address is in `ff01::/16`, otherwise `false`.
130
+ * @since v0.0.2
131
+ */
98
132
  isMulticastInterfaceLocal(): boolean;
99
133
  /**
100
- * Checks whether this address is a multicast link-local address.
101
- * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
102
- * @returns `true` when the address is in `ff02::/16`, otherwise `false`.
103
- * @since v0.0.2
104
- */
134
+ * Checks whether this address is a multicast link-local address.
135
+ * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
136
+ * @returns `true` when the address is in `ff02::/16`, otherwise `false`.
137
+ * @since v0.0.2
138
+ */
105
139
  isMulticastLinkLocal(): boolean;
106
140
  /**
107
- * Checks whether this address is a multicast realm-local address.
108
- * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
109
- * @returns `true` when the address is in `ff03::/16`, otherwise `false`.
110
- * @since v0.0.2
111
- */
141
+ * Checks whether this address is the all-nodes multicast group address.
142
+ * @returns `true` when the address is multicast and the group ID is 1, otherwise `false`.
143
+ * @since v0.2.0
144
+ */
145
+ isAllNodesMulticastGroup(): boolean;
146
+ /**
147
+ * Checks whether this address is the all-routers multicast group address.
148
+ * @returns `true` when the address is multicast and the group ID is 2, otherwise `false`.
149
+ * @since v0.2.0
150
+ */
151
+ isAllRoutersMulticastGroup(): boolean;
152
+ /**
153
+ * Checks whether this address is the mDNS multicast group address.
154
+ * @returns `true` when the address is `ff02::fb`, otherwise `false`.
155
+ * @since v0.2.0
156
+ */
157
+ isMdnsMulticastGroup(): boolean;
158
+ /**
159
+ * Checks whether this address is the SSDP multicast group address.
160
+ * @returns `true` when the address is `ff02::c`, otherwise `false`.
161
+ * @since v0.2.0
162
+ */
163
+ isSsdpMulticastGroup(): boolean;
164
+ /**
165
+ * Checks whether this address is the DHCPv6 multicast group address.
166
+ * @returns `true` when the address is `ff02::12`, otherwise `false`.
167
+ * @since v0.2.0
168
+ */
169
+ isDhcpv6MulticastGroup(): boolean;
170
+ /**
171
+ * Checks whether this address is a multicast realm-local address.
172
+ * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
173
+ * @returns `true` when the address is in `ff03::/16`, otherwise `false`.
174
+ * @since v0.0.2
175
+ */
112
176
  isMulticastRealmLocal(): boolean;
113
177
  /**
114
- * Checks whether this address is a multicast admin-local address.
115
- * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
116
- * @returns `true` when the address is in `ff04::/16`, otherwise `false`.
117
- * @since v0.0.2
118
- */
178
+ * Checks whether this address is a multicast admin-local address.
179
+ * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
180
+ * @returns `true` when the address is in `ff04::/16`, otherwise `false`.
181
+ * @since v0.0.2
182
+ */
119
183
  isMulticastAdminLocal(): boolean;
120
184
  /**
121
- * Checks whether this address is a multicast site-local address.
122
- * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
123
- * @returns `true` when the address is in `ff05::/16`, otherwise `false`.
124
- * @since v0.0.2
125
- */
185
+ * Checks whether this address is a multicast site-local address.
186
+ * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
187
+ * @returns `true` when the address is in `ff05::/16`, otherwise `false`.
188
+ * @since v0.0.2
189
+ */
126
190
  isMulticastSiteLocal(): boolean;
127
191
  /**
128
- * Checks whether this address is a multicast organization-local address.
129
- * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
130
- * @returns `true` when the address is in `ff08::/16`, otherwise `false`.
131
- * @since v0.0.2
132
- */
192
+ * Checks whether this address is a multicast organization-local address.
193
+ * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
194
+ * @returns `true` when the address is in `ff08::/16`, otherwise `false`.
195
+ * @since v0.0.2
196
+ */
133
197
  isMulticastOrganizationLocal(): boolean;
134
198
  /**
135
- * Checks whether this address is a multicast global address.
136
- * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
137
- * @returns `true` when the address is in `ff0e::/16`, otherwise `false`.
138
- * @since v0.0.2
139
- */
199
+ * Checks whether this address is a multicast global address.
200
+ * @see https://datatracker.ietf.org/doc/html/rfc4291#section-2.7
201
+ * @returns `true` when the address is in `ff0e::/16`, otherwise `false`.
202
+ * @since v0.0.2
203
+ */
140
204
  isMulticastGlobal(): boolean;
141
205
  /**
142
- * Checks whether this address is an IPv4-mapped IPv6 address.
143
- * @returns `true` when the address is in `::ffff:0:0/96`, otherwise `false`.
144
- * @since v0.0.1
145
- */
206
+ * Checks whether this address is an IPv4-mapped IPv6 address.
207
+ * @returns `true` when the address is in `::ffff:0:0/96`, otherwise `false`.
208
+ * @since v0.0.1
209
+ */
146
210
  isIpv4Mapped(): boolean;
147
211
  /**
148
- * Checks whether this address is a unicast address.
149
- * @see https://tools.ietf.org/html/rfc4291
150
- * @returns `true` when the address is not multicast, otherwise `false`.
151
- * @since v0.0.1
152
- */
212
+ * Checks whether this address is a unicast address.
213
+ * @see https://tools.ietf.org/html/rfc4291
214
+ * @returns `true` when the address is not multicast, otherwise `false`.
215
+ * @since v0.0.1
216
+ */
153
217
  isUnicast(): boolean;
154
218
  /**
155
- * Checks whether this address is a link-local unicast address.
156
- * @see https://tools.ietf.org/html/rfc4291
157
- * @returns `true` when the address is in `fe80::/10`, otherwise `false`.
158
- * @since v0.0.1
159
- */
219
+ * Checks whether this address is a link-local unicast address.
220
+ * @see https://tools.ietf.org/html/rfc4291
221
+ * @returns `true` when the address is in `fe80::/10`, otherwise `false`.
222
+ * @since v0.0.1
223
+ */
160
224
  isUnicastLinkLocal(): boolean;
161
225
  /**
162
- * Checks whether this address is a global unicast address.
163
- * @see https://tools.ietf.org/html/rfc4291#section-2.5.7
164
- * @returns `true` when the address is unicast and not loopback, link-local, private, unspecified, or documentation.
165
- * @since v0.0.1
166
- */
226
+ * Checks whether this address is a global unicast address.
227
+ * @see https://tools.ietf.org/html/rfc4291#section-2.5.7
228
+ * @returns `true` when the address is unicast and not loopback, link-local, private, unspecified, or documentation.
229
+ * @since v0.0.1
230
+ */
167
231
  isUnicastGlobal(): boolean;
168
232
  /**
169
- * Checks whether this address appears globally reachable.
170
- * @see https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml
171
- * @returns `true` when the address is not in known non-global special ranges.
172
- * @since v0.0.1
173
- */
233
+ * Checks whether this address appears globally reachable.
234
+ * @see https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml
235
+ * @returns `true` when the address is not in known non-global special ranges.
236
+ * @since v0.0.1
237
+ */
174
238
  isGlobal(): boolean;
175
239
  /**
176
- * Checks whether this address is in the unique-local range.
177
- * @see https://tools.ietf.org/html/rfc4193
178
- * @returns `true` when the address is in `fc00::/7`, otherwise `false`.
179
- * @since v0.0.1
180
- */
240
+ * Checks whether this address is in the unique-local range.
241
+ * @see https://tools.ietf.org/html/rfc4193
242
+ * @returns `true` when the address is in `fc00::/7`, otherwise `false`.
243
+ * @since v0.0.1
244
+ */
181
245
  isUniqueLocal(): boolean;
182
246
  /**
183
- * Converts this address to IPv4 when compatible or mapped.
184
- * @returns An IPv4 address for `::a.b.c.d` or `::ffff:a.b.c.d`; otherwise `None`.
185
- * @since v0.0.1
186
- */
187
- toIpv4(): IOption<Ipv4Addr>;
188
- /**
189
- * Converts this address to IPv4 only when it is IPv4-mapped.
190
- * @returns An IPv4 address for `::ffff:a.b.c.d`; otherwise `None`.
191
- * @since v0.0.1
192
- */
193
- toIpv4Mapped(): IOption<Ipv4Addr>;
194
- /**
195
- * Formats this address as a compressed IPv6 string.
196
- * @returns The shortest standard IPv6 text form.
197
- * @since v0.0.1
198
- */
247
+ * Converts this address to IPv4 when compatible or mapped.
248
+ * @returns A {@link CoreResult} containing either the resulting {@link Ipv4Addr} or a {@link RangeError} if the address is not IPv4 compatible or mapped.
249
+ * @since v0.0.1
250
+ */
251
+ toIpv4(): CoreResult<Ipv4Addr, RangeError>;
252
+ /**
253
+ * Converts this address to IPv4 when compatible or mapped, throwing on failure.
254
+ * @returns An {@link Ipv4Addr} for `::a.b.c.d` or `::ffff:a.b.c.d`.
255
+ * @throws {RangeError} If the address is not IPv4 compatible or mapped.
256
+ * @since v0.2.0
257
+ */
258
+ toIpv4OrThrow(): Ipv4Addr;
259
+ /**
260
+ * Converts this address to IPv4 only when it is IPv4-mapped.
261
+ * @returns A {@link CoreResult} containing either the resulting {@link Ipv4Addr} or a {@link RangeError} if the address is not IPv4 mapped.
262
+ * @since v0.0.1
263
+ */
264
+ toIpv4Mapped(): CoreResult<Ipv4Addr, RangeError>;
265
+ /**
266
+ * Converts this address to IPv4 only when it is IPv4-mapped, throwing on failure.
267
+ * @returns An {@link Ipv4Addr} address for `::ffff:a.b.c.d`.
268
+ * @throws {RangeError} If the address is not IPv4 mapped.
269
+ * @since v0.2.0
270
+ */
271
+ toIpv4MappedOrThrow(): Ipv4Addr;
272
+ /**
273
+ * Formats this address as a compressed IPv6 string.
274
+ * @returns The shortest standard IPv6 text form.
275
+ * @since v0.0.1
276
+ */
199
277
  toString(): string;
200
278
  /**
201
- * Encodes this address to a 16-byte buffer.
202
- * @param littleEndian Whether to use little-endian byte order. Defaults to `false`.
203
- * @returns An `ArrayBuffer` containing the IPv6 integer value.
204
- * @since v0.0.1
205
- */
279
+ * Converts this address to its fully expanded IPv6 string representation.
280
+ * @returns The expanded IPv6 string (e.g., `2001:0db8:0000:0000:0000:ff00:0042:8329`).
281
+ * @since v0.2.0
282
+ */
283
+ toExpandedString(): string;
284
+ /**
285
+ * Encodes this address to a 16-byte buffer.
286
+ * @param littleEndian Whether to use little-endian byte order. Defaults to `false`.
287
+ * @returns An {@link ArrayBuffer} containing the IPv6 integer value.
288
+ * @since v0.0.1
289
+ */
206
290
  toBuffer(littleEndian?: boolean): ArrayBuffer;
207
291
  /**
208
- * Compares this IPv6 address with another for equality.
209
- * @param other instance of another IPv6 address to compare with.
210
- * @returns `true` if both addresses are equal, otherwise `false`.
211
- * @since v0.1.0
212
- */
213
- equals(other: Ipv6Addr | Ipv4Addr | object): boolean;
292
+ * Compares this address with another for equality.
293
+ * @param other instance of another {@link Ipv6Addr} or {@link Ipv4Addr} address to compare with.
294
+ * @returns `true` if both addresses are equal, otherwise `false`.
295
+ * @since v0.1.0
296
+ */
297
+ equals(other?: unknown): boolean;
214
298
  }
215
299
  //#endregion
216
300
  //#region src/Ipv4Addr.d.ts
217
301
  /**
218
- * Represents an IPv4 address.
219
- * @example
220
- * const addr1 = Ipv4Addr.from('192.168.0.1').unwrap();
221
- * const addr2 = new Ipv4Addr(192, 168, 0, 1);
222
- * const addr3 = new Ipv4Addr(0xc0a80001);
223
- * @since v0.0.1
224
- */
225
- declare class Ipv4Addr {
302
+ * Represents an IPv4 address.
303
+ * @example
304
+ * const addr1Res = Ipv4Addr.from('192.168.0.1');
305
+ * const addr1 = Ipv4Addr.fromOrThrow('192.168.0.1');
306
+ * const addr2 = new Ipv4Addr(192, 168, 0, 1);
307
+ * const addr3 = new Ipv4Addr(0xc0a80001);
308
+ * @since v0.0.1
309
+ */
310
+ export declare class Ipv4Addr {
226
311
  #private;
227
312
  /**
228
- * Creates an IPv4 address from dotted-decimal text.
229
- * @returns A successful {@link IResult} with an IPv4 address, or an error when the input is invalid.
230
- * @since v0.0.1
231
- */
232
- static from(value: string): IResult<Ipv4Addr, TypeError>;
233
- /**
234
- * Creates an IPv4 address from a 4-byte buffer.
235
- * @returns A successful {@link IResult} with an IPv4 address, or an error when the buffer cannot be read.
236
- * @since v0.0.1
237
- */
238
- static fromBuffer(buffer: ArrayBuffer, littleEndian?: boolean): IResult<Ipv4Addr>;
239
- /**
240
- * The number of bits in an IPv4 address.
241
- * @since v0.0.1
242
- */
313
+ * Creates an IPv4 address from dotted-decimal text.
314
+ * @returns A successful {@link CoreResult} with an {@link Ipv4Addr}, or an {@link TypeError} when the input is invalid.
315
+ * @example
316
+ * const addr: CoreResult<Ipv4Addr, TypeError> = Ipv4Addr.from('192.168.0.1');
317
+ * @since v0.0.1
318
+ */
319
+ static from(value: string): CoreResult<Ipv4Addr, TypeError>;
320
+ /**
321
+ * Creates an IPv4 address from text and throws an error if the input is invalid.
322
+ * @param value The IPv4 address in string format.
323
+ * @returns The {@link Ipv4Addr} instance.
324
+ * @throws {TypeError} If the input is not a valid IPv4 address.
325
+ * @example
326
+ * const addr: Ipv4Addr = Ipv4Addr.fromOrThrow('192.168.0.1');
327
+ * @since v0.2.0
328
+ */
329
+ static fromOrThrow(value: string): Ipv4Addr;
330
+ /**
331
+ * Creates an IPv4 address from a 4-byte buffer.
332
+ * @returns A successful {@link CoreResult} with an {@link Ipv4Addr}, or an {@link Error} when the buffer cannot be read.
333
+ * @example
334
+ * const result: CoreResult<Ipv4Addr, Error> = Ipv4Addr.fromBuffer(buffer);
335
+ * @since v0.0.1
336
+ */
337
+ static fromBuffer(buffer: ArrayBuffer, littleEndian?: boolean): CoreResult<Ipv4Addr, Error>;
338
+ /**
339
+ * Creates an IPv4 address from a 4-byte buffer and throws an error if the buffer cannot be read.
340
+ * @param buffer The 4-byte buffer containing the IPv4 address.
341
+ * @param littleEndian Whether the buffer is in little-endian format. Defaults to false (big-endian).
342
+ * @returns The {@link Ipv4Addr} instance.
343
+ * @throws {Error} If the buffer cannot be read.
344
+ * @example
345
+ * const addr: Ipv4Addr = Ipv4Addr.fromBufferOrThrow(buffer);
346
+ * @since v0.2.0
347
+ */
348
+ static fromBufferOrThrow(buffer: ArrayBuffer, littleEndian?: boolean): Ipv4Addr;
349
+ /**
350
+ * The number of bits in an IPv4 address.
351
+ * @since v0.0.1
352
+ * @see https://doc.rust-lang.org/stable/std/net/struct.Ipv4Addr.html#associatedconstant.BITS
353
+ */
243
354
  static readonly BITS = 32;
244
355
  /**
245
- * The broadcast address `255.255.255.255`.
246
- * @since v0.0.1
247
- */
356
+ * The broadcast address `255.255.255.255`.
357
+ * @since v0.0.1
358
+ * @see https://doc.rust-lang.org/stable/std/net/struct.Ipv4Addr.html#associatedconstant.BROADCAST
359
+ */
248
360
  static readonly BROADCAST: Ipv4Addr;
249
361
  /**
250
- * The localhost address `127.0.0.1`.
251
- * @since v0.0.1
252
- */
362
+ * The localhost address `127.0.0.1`.
363
+ * @since v0.0.1
364
+ * @see https://doc.rust-lang.org/stable/std/net/struct.Ipv4Addr.html#associatedconstant.LOCALHOST
365
+ */
253
366
  static readonly LOCALHOST: Ipv4Addr;
254
367
  /**
255
- * The unspecified address `0.0.0.0`.
256
- * @since v0.0.1
257
- */
368
+ * The unspecified address `0.0.0.0`.
369
+ * @since v0.0.1
370
+ * @see https://doc.rust-lang.org/stable/std/net/struct.Ipv4Addr.html#associatedconstant.UNSPECIFIED
371
+ */
258
372
  static readonly UNSPECIFIED: Ipv4Addr;
259
373
  /**
260
- * The address family identifier for IPv4 addresses.
261
- * @since v0.0.1
262
- */
374
+ * The address family identifier for IPv4 addresses.
375
+ * @since v0.0.1
376
+ */
263
377
  readonly family = "ipv4";
264
378
  /**
265
- * Creates a new IPv4 address from four octets.
266
- * @param num1 The first octet.
267
- * @param num2 The second octet.
268
- * @param num3 The third octet.
269
- * @param num4 The fourth octet.
270
- * @throws {RangeError} If the integer values are not in the range of 0 to 255 for each octet.
271
- * @throws {TypeError} If the input is not a number.
272
- * @example
273
- * new Ipv4Addr(192, 168, 0, 1) // creates the address `192.168.0.1`
274
- */
379
+ * Gets the raw integer representation of the IPv4 address.
380
+ */
381
+ get value(): number;
382
+ /**
383
+ * Creates a new IPv4 address from four octets.
384
+ * @param num1 The first octet.
385
+ * @param num2 The second octet.
386
+ * @param num3 The third octet.
387
+ * @param num4 The fourth octet.
388
+ * @throws {RangeError} If the integer values are not in the range of 0 to 255 for each octet.
389
+ * @throws {TypeError} If the input is not a number.
390
+ * @example
391
+ * new Ipv4Addr(192, 168, 0, 1) // creates the address `192.168.0.1`
392
+ */
275
393
  constructor(num1: number, num2: number, num3: number, num4: number);
276
394
  /**
277
- * Creates a new IPv4 address from an integer value.
278
- * @param integerValue The integer representation of the IPv4 address.
279
- * @throws {RangeError} If the integer value is not in the range of 0 to 0xffffffff.
280
- * @throws {TypeError} If the input is not a number.
281
- * @example
282
- * new Ipv4Addr(0xc0a80001) // creates the address `192.168.0.1` from the integer value `0xc0a80001`
283
- */
395
+ * Creates a new IPv4 address from an integer value.
396
+ * @param integerValue The integer representation of the IPv4 address.
397
+ * @throws {RangeError} If the integer value is not in the range of 0 to 0xffffffff.
398
+ * @throws {TypeError} If the input is not a number.
399
+ * @example
400
+ * new Ipv4Addr(0xc0a80001) // creates the address `192.168.0.1` from the integer value `0xc0a80001`
401
+ */
284
402
  constructor(integerValue: number);
285
403
  /**
286
- * Checks whether this address is the broadcast address.
287
- * @see https://datatracker.ietf.org/doc/html/rfc919#section-7
288
- * @returns `true` when the address is `255.255.255.255`, otherwise `false`.
289
- * @since v0.0.1
290
- */
404
+ * Checks whether this address is the broadcast address.
405
+ * @see https://datatracker.ietf.org/doc/html/rfc919#section-7
406
+ * @returns `true` when the address is `255.255.255.255`, otherwise `false`.
407
+ * @since v0.0.1
408
+ */
291
409
  isBroadcast(): boolean;
292
410
  /**
293
- * Checks whether this address is in a documentation-only range.
294
- * @see https://datatracker.ietf.org/doc/html/rfc5737
295
- * @returns `true` for `192.0.2.0/24`, `198.51.100.0/24`, or `203.0.113.0/24`; otherwise `false`.
296
- * @since v0.0.1
297
- */
411
+ * Checks whether this address is in a documentation-only range.
412
+ * @see https://datatracker.ietf.org/doc/html/rfc5737
413
+ * @returns `true` for `192.0.2.0/24`, `198.51.100.0/24`, or `203.0.113.0/24`; otherwise `false`.
414
+ * @since v0.0.1
415
+ */
298
416
  isDocumentation(): boolean;
299
417
  /**
300
- * Checks whether this address is in the benchmarking range.
301
- * @see https://datatracker.ietf.org/doc/html/rfc2544
302
- * @returns `true` when the address is in `198.18.0.0/15`, otherwise `false`.
303
- * @since v0.0.1
304
- */
418
+ * Checks whether this address is in the benchmarking range.
419
+ * @see https://datatracker.ietf.org/doc/html/rfc2544
420
+ * @returns `true` when the address is in `198.18.0.0/15`, otherwise `false`.
421
+ * @since v0.0.1
422
+ */
305
423
  isBenchmarking(): boolean;
306
424
  /**
307
- * Checks whether this address is globally reachable.
308
- * @see https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
309
- * @returns `true` when the address is not in any special non-global range.
310
- * @since v0.0.1
311
- */
425
+ * Checks whether this address is globally reachable.
426
+ * @see https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
427
+ * @returns `true` when the address is not in any special non-global range.
428
+ * @since v0.0.1
429
+ */
312
430
  isGlobal(): boolean;
313
431
  /**
314
- * Checks whether this address is link-local.
315
- * @see https://datatracker.ietf.org/doc/html/rfc3927
316
- * @returns `true` when the address is in `169.254.0.0/16`, otherwise `false`.
317
- * @since v0.0.1
318
- */
432
+ * Checks whether this address is link-local.
433
+ * @see https://datatracker.ietf.org/doc/html/rfc3927
434
+ * @returns `true` when the address is in `169.254.0.0/16`, otherwise `false`.
435
+ * @since v0.0.1
436
+ */
319
437
  isLinkLocal(): boolean;
320
438
  /**
321
- * Checks whether this address is a loopback address.
322
- * @see https://datatracker.ietf.org/doc/html/rfc1122
323
- * @returns `true` when the address is in `127.0.0.0/8`, otherwise `false`.
324
- * @since v0.0.1
325
- */
439
+ * Checks whether this address is a loopback address.
440
+ * @see https://datatracker.ietf.org/doc/html/rfc1122
441
+ * @returns `true` when the address is in `127.0.0.0/8`, otherwise `false`.
442
+ * @since v0.0.1
443
+ */
326
444
  isLoopback(): boolean;
327
445
  /**
328
- * Checks whether this address is a multicast address.
329
- * @see https://datatracker.ietf.org/doc/html/rfc5771
330
- * @returns `true` when the address is in `224.0.0.0/4`, otherwise `false`.
331
- * @since v0.0.1
332
- */
446
+ * Checks whether this address is a multicast address.
447
+ * @see https://datatracker.ietf.org/doc/html/rfc5771
448
+ * @returns `true` when the address is in `224.0.0.0/4`, otherwise `false`.
449
+ * @since v0.0.1
450
+ */
333
451
  isMulticast(): boolean;
334
452
  /**
335
- * Checks whether this address is in a private-use range.
336
- * @see https://datatracker.ietf.org/doc/html/rfc1918
337
- * @returns `true` for `10.0.0.0/8`, `172.16.0.0/12`, or `192.168.0.0/16`; otherwise `false`.
338
- * @since v0.0.1
339
- */
453
+ * Checks whether this address is in a private-use range.
454
+ * @see https://datatracker.ietf.org/doc/html/rfc1918
455
+ * @returns `true` for `10.0.0.0/8`, `172.16.0.0/12`, or `192.168.0.0/16`; otherwise `false`.
456
+ * @since v0.0.1
457
+ */
340
458
  isPrivate(): boolean;
341
459
  /**
342
- * Checks whether this address is in the reserved range.
343
- * @see https://datatracker.ietf.org/doc/html/rfc1112
344
- * @returns `true` when the address is in `240.0.0.0/4` except the broadcast address.
345
- * @since v0.0.1
346
- */
460
+ * Checks whether this address is in the reserved range.
461
+ * @see https://datatracker.ietf.org/doc/html/rfc1112
462
+ * @returns `true` when the address is in `240.0.0.0/4` except the broadcast address.
463
+ * @since v0.0.1
464
+ */
347
465
  isReserved(): boolean;
348
466
  /**
349
- * Checks whether this address is in the shared Carrier-Grade NAT range.
350
- * @see https://datatracker.ietf.org/doc/html/rfc6598
351
- * @returns `true` when the address is in `100.64.0.0/10`, otherwise `false`.
352
- * @since v0.0.1
353
- */
467
+ * Checks whether this address is in the shared Carrier-Grade NAT range.
468
+ * @see https://datatracker.ietf.org/doc/html/rfc6598
469
+ * @returns `true` when the address is in `100.64.0.0/10`, otherwise `false`.
470
+ * @since v0.0.1
471
+ * @see https://doc.rust-lang.org/stable/std/net/struct.Ipv4Addr.html#method.is_shared
472
+ */
354
473
  isShared(): boolean;
355
474
  /**
356
- * Checks whether this address is the unspecified address.
357
- * @returns `true` when the address is `0.0.0.0`, otherwise `false`.
358
- * @since v0.0.1
359
- */
475
+ * Checks whether this address is the unspecified address.
476
+ * @returns `true` when the address is `0.0.0.0`, otherwise `false`.
477
+ * @since v0.0.1
478
+ * @see https://doc.rust-lang.org/stable/std/net/struct.Ipv4Addr.html#method.is_unspecified
479
+ */
360
480
  isUnspecified(): boolean;
361
481
  /**
362
- * Converts this address to an IPv4-compatible IPv6 address.
363
- * @returns An IPv6 address in the form `::a.b.c.d`.
364
- * @since v0.0.1
365
- */
482
+ * Gets the four octets of this IPv4 address.
483
+ * @returns An array containing the four octets `[num1, num2, num3, num4]`.
484
+ * @see https://doc.rust-lang.org/stable/std/net/struct.Ipv4Addr.html#method.octets
485
+ * @since v0.2.0
486
+ */
487
+ toOctets(): [number, number, number, number];
488
+ /**
489
+ * Converts this address to an IPv4-compatible {@link Ipv6Addr}.
490
+ * @returns An {@link Ipv6Addr} in the form `::a.b.c.d`.
491
+ * @since v0.0.1
492
+ */
366
493
  toIpv6(): Ipv6Addr;
367
494
  /**
368
- * Converts this address to an IPv4-mapped IPv6 address.
369
- * @returns An IPv6 address in the form `::ffff:a.b.c.d`.
370
- * @since v0.0.1
371
- */
495
+ * Converts this address to an IPv4-mapped {@link Ipv6Addr}.
496
+ * @returns An {@link Ipv6Addr} in the form `::ffff:a.b.c.d`.
497
+ * @since v0.0.1
498
+ */
372
499
  toIpv6Mapped(): Ipv6Addr;
373
500
  /**
374
- * Formats this address as dotted-decimal text.
375
- * @returns The IPv4 string representation, such as `192.168.0.1`.
376
- * @since v0.0.1
377
- */
501
+ * Formats this address as dotted-decimal text.
502
+ * @returns The IPv4 string representation, such as `192.168.0.1`.
503
+ * @since v0.0.1
504
+ */
378
505
  toString(): string;
379
506
  /**
380
- * Encodes this address to a 4-byte buffer.
381
- * @returns An `ArrayBuffer` containing the IPv4 integer value.
382
- * @since v0.0.1
383
- */
507
+ * Encodes this address to a 4-byte buffer.
508
+ * @returns An {@link ArrayBuffer} containing the IPv4 integer value.
509
+ * @since v0.0.1
510
+ * @example
511
+ * const buffer: ArrayBuffer = addr.toBuffer();
512
+ */
384
513
  toBuffer(littleEndian?: boolean): ArrayBuffer;
385
514
  /**
386
- * Compares this IPv4 address with another for equality.
387
- * @param other instance of another IPv4 address to compare with.
388
- * @returns `true` if both addresses are equal, otherwise `false`.
389
- * @since v0.1.0
390
- */
391
- equals(other: Ipv4Addr | Ipv6Addr | object): boolean;
515
+ * Compares this IPv4 address with another for equality.
516
+ * @param other instance of another address like to compare with.
517
+ * @returns `true` if both addresses are equal, otherwise `false`.
518
+ * @since v0.1.0
519
+ */
520
+ equals(other?: unknown): boolean;
521
+ }
522
+ //#endregion
523
+ //#region src/Ipv4Net.d.ts
524
+ /**
525
+ * Represents an IPv4 network.
526
+ * @example
527
+ * const addrRes = Ipv4Addr.from('192.168.0.1');
528
+ * const addr = Ipv4Addr.fromOrThrow('192.168.0.1');
529
+ * const network = Ipv4Net.fromAddr(addr, 24);
530
+ * @since v0.1.2
531
+ */
532
+ export declare class Ipv4Net {
533
+ #private;
534
+ /**
535
+ * Size of the network (subnet mask length).
536
+ * @since v0.1.2
537
+ */
538
+ readonly size: number;
539
+ /**
540
+ * Address family of the network.
541
+ * @since v0.1.2
542
+ */
543
+ readonly family: "ipv4";
544
+ private constructor();
545
+ /**
546
+ * Creates an IPv4 network from address and a subnet mask length.
547
+ * @param address The starting {@link Ipv4Addr} of the network.
548
+ * @param size The size of the network (subnet mask length).
549
+ * @returns A {@link CoreResult} containing the parsed {@link Ipv4Net} instance or a {@link RangeError} if the network size is invalid.
550
+ * @example
551
+ * const networkRes: CoreResult<Ipv4Net, RangeError> = Ipv4Net.fromAddr(addr, 24);
552
+ * @since v0.2.0
553
+ */
554
+ static fromAddr(address: Ipv4Addr, size: number): CoreResult<Ipv4Net, RangeError>;
555
+ /**
556
+ * Creates an IPv4 network from address and a subnet mask length, throwing an error if creation fails.
557
+ * @param address The starting {@link Ipv4Addr} of the network.
558
+ * @param size The size of the network (subnet mask length).
559
+ * @returns The parsed {@link Ipv4Net} instance.
560
+ * @throws {RangeError} If the network size is invalid.
561
+ * @example
562
+ * const network: Ipv4Net = Ipv4Net.fromAddrOrThrow(addr, 24);
563
+ * @since v0.2.0
564
+ */
565
+ static fromAddrOrThrow(address: Ipv4Addr, size: number): Ipv4Net;
566
+ /**
567
+ * Creates an IPv4 network from its string representation.
568
+ * @param value The string representation of the IPv4 network, e.g., `192.168.0.1/24`.
569
+ * @returns A {@link CoreResult} containing the parsed {@link Ipv4Net} instance or a {@link TypeError} if parsing fails.
570
+ * @example
571
+ * const networkRes: CoreResult<Ipv4Net, TypeError> = Ipv4Net.from('192.168.0.1/24');
572
+ * @since v0.2.0
573
+ */
574
+ static from(value: string): CoreResult<Ipv4Net, TypeError>;
575
+ /**
576
+ * Creates an IPv4 network from its string representation, throwing an error if parsing fails.
577
+ * @param value The string representation of the IPv4 network, e.g., `192.168.0.1/24`.
578
+ * @returns The parsed {@link Ipv4Net} instance.
579
+ * @throws {TypeError} If the string representation is invalid.
580
+ * @example
581
+ * const network: Ipv4Net = Ipv4Net.fromOrThrow('192.168.0.1/24');
582
+ * @since v0.2.0
583
+ */
584
+ static fromOrThrow(value: string): Ipv4Net;
585
+ /**
586
+ * Checks if the given IPv4 address is contained within the network.
587
+ * @param addr The {@link Ipv4Addr} to check.
588
+ * @returns `true` if the given address is contained within the network, otherwise `false`.
589
+ * @since v0.2.0
590
+ */
591
+ contains(addr: Ipv4Addr): boolean;
592
+ /**
593
+ * Gets the broadcast address of the network.
594
+ * @returns The broadcast address as an {@link Ipv4Addr} instance.
595
+ * @since v0.2.0
596
+ */
597
+ broadcast(): Ipv4Addr;
598
+ /**
599
+ * Gets the network mask of the IPv4 network.
600
+ * @returns The network mask as an {@link Ipv4Addr} instance.
601
+ * @since v0.2.0
602
+ */
603
+ netmask(): Ipv4Addr;
604
+ /**
605
+ * Gets the string representation of the IPv4 network.
606
+ * @returns The IPv4 network as a string, e.g., `192.168.0.1/24`.
607
+ * @since v0.2.0
608
+ */
609
+ toString(): string;
610
+ /**
611
+ * Gets the first address within the network.
612
+ * @returns The first address as an {@link Ipv4Addr} instance.
613
+ * @since v0.2.0
614
+ */
615
+ first(): Ipv4Addr;
616
+ /**
617
+ * Gets the last address within the network.
618
+ * @returns The last address as an {@link Ipv4Addr} instance.
619
+ * @since v0.2.0
620
+ */
621
+ last(): Ipv4Addr;
622
+ /**
623
+ * Gets the first usable address within the network.
624
+ * @returns The first usable address as an {@link Ipv4Addr} instance.
625
+ * @since v0.2.0
626
+ */
627
+ firstUsable(): Ipv4Addr;
628
+ /**
629
+ * Gets the last usable address within the network.
630
+ * @returns The last usable address as an {@link Ipv4Addr} instance.
631
+ * @since v0.2.0
632
+ */
633
+ lastUsable(): Ipv4Addr;
634
+ /**
635
+ * Checks if the current network is equal to another network.
636
+ * @param other The other network to compare with.
637
+ * @returns `true` if the networks are equal, otherwise `false`.
638
+ * @example
639
+ * const isEqual = Ipv4Net.fromOrThrow('192.168.0.0/24').equals(Ipv4Net.fromOrThrow('192.168.0.0/24'));
640
+ * @since v0.2.0
641
+ */
642
+ equals(other?: unknown): boolean;
643
+ /**
644
+ * Assigns an address to the current network, effectively combining the network with the given address.
645
+ * @param value The other IPv4 address to combine with (e.g., `0.0.0.100`)
646
+ * @returns The combined IPv4 address as a {@link CoreResult} containing either the resulting {@link Ipv4Addr} or a {@link RangeError} if the address does not fit within the host portion of the network.
647
+ * @example
648
+ * const network = Ipv4Net.fromOrThrow('192.168.0.0/24');
649
+ * const result: CoreResult<Ipv4Addr, RangeError | TypeError> = network.assignAddress('0.0.0.100');
650
+ * const result: CoreResult<Ipv4Addr, RangeError | TypeError> = network.assignAddress(Ipv4Addr.fromOrThrow('0.0.0.100'))
651
+ * @since v0.2.0
652
+ */
653
+ assignAddress(value: Ipv4Addr | string): CoreResult<Ipv4Addr, RangeError | TypeError>;
654
+ /**
655
+ * Assigns an address to the current network, effectively combining the network with the given address.
656
+ * @param other The other IPv4 address to combine with (e.g., `0.0.0.100`)
657
+ * @returns The combined IPv4 address as an {@link Ipv4Addr} instance. (e.g., combining `192.168.0.0/24` with `0.0.0.100` would result in `192.168.0.100`)
658
+ * @throws {RangeError} If the given address does not fit within the host portion of the network.
659
+ * @example
660
+ * const network = Ipv4Net.fromOrThrow('192.168.0.0/24');
661
+ * const combined = network.assignAddressOrThrow('0.0.0.100'); // Ipv4Addr(192.168.0.100)
662
+ * const combined = network.assignAddressOrThrow(Ipv4Addr.fromOrThrow('0.0.0.100')); // Ipv4Addr(192.168.0.100)
663
+ * @since v0.2.0
664
+ */
665
+ assignAddressOrThrow(other: Ipv4Addr | string): Ipv4Addr;
666
+ /**
667
+ * Checks if the current network is a subnet of the given parent network.
668
+ * @param parent The parent network to check against.
669
+ * @returns `true` if the current network is a subnet of the parent network, `false` otherwise.
670
+ * @since v0.2.0
671
+ */
672
+ isSubnetOf(parent: Ipv4Net): boolean;
673
+ /**
674
+ * Checks if the current network contains the given child network.
675
+ * @param child The child network to check for containment.
676
+ * @returns `true` if the current network contains the child network, `false` otherwise.
677
+ * @since v0.2.0
678
+ */
679
+ containsNet(child: Ipv4Net): boolean;
680
+ /**
681
+ * Returns an iterable of all addresses within the network.
682
+ * @returns An {@link Ipv4Addr} {@link Iterable} of all addresses within the network.
683
+ * @since v0.2.0
684
+ */
685
+ addresses(): Iterable<Ipv4Addr>;
686
+ /**
687
+ * Returns an iterable of all usable host addresses within the network.
688
+ * @returns An {@link Ipv4Addr} {@link Iterable} of all usable host addresses within the network.
689
+ * @since v0.2.0
690
+ */
691
+ hosts(): Iterable<Ipv4Addr>;
692
+ }
693
+ //#endregion
694
+ //#region src/Ipv6Net.d.ts
695
+ /**
696
+ * Represents an IPv6 network.
697
+ * @example
698
+ * const addrRes = Ipv6Addr.from('2001:db8::1');
699
+ * const addr = Ipv6Addr.fromOrThrow('2001:db8::1');
700
+ * const network = Ipv6Net.fromAddr(addr, 64);
701
+ * @since v0.1.2
702
+ */
703
+ export declare class Ipv6Net {
704
+ #private;
705
+ /**
706
+ * Size of the network (prefix length).
707
+ * @since v0.1.2
708
+ */
709
+ readonly size: number;
710
+ /**
711
+ * Address family of the network.
712
+ * @since v0.1.2
713
+ */
714
+ readonly family: "ipv6";
715
+ private constructor();
716
+ /**
717
+ * Creates an instance of {@link Ipv6Net} from {@link Ipv6Addr} and network size.
718
+ * @param address The interface address as an {@link Ipv6Addr} instance.
719
+ * @param size The network size (prefix length) as a number.
720
+ * @returns A {@link CoreResult} containing the instance of {@link Ipv6Net} if successful, or a {@link RangeError} if the network size is invalid.
721
+ * @since v0.1.2
722
+ */
723
+ static fromAddr(address: Ipv6Addr, size: number): CoreResult<Ipv6Net, RangeError>;
724
+ /**
725
+ * Creates an instance of {@link Ipv6Net} from {@link Ipv6Addr} and network size, throwing an error if the size is invalid.
726
+ * @param address The interface address as an {@link Ipv6Addr} instance.
727
+ * @param size The network size (prefix length) as a number.
728
+ * @returns An instance of {@link Ipv6Net}.
729
+ * @throws {RangeError} If the network size is not between 0 and 128.
730
+ * @since v0.2.0
731
+ */
732
+ static fromAddrOrThrow(address: Ipv6Addr, size: number): Ipv6Net;
733
+ /**
734
+ * Creates an instance of {@link Ipv6Net} from a string representation.
735
+ * @param value The string representation of the IPv6 network, e.g., `2001:db8::/64` or full interface address with size.
736
+ * @returns A {@link CoreResult} containing the instance of {@link Ipv6Net} if successful, or a {@link TypeError} if the input is invalid.
737
+ * @since v0.1.2
738
+ */
739
+ static from(value: string): CoreResult<Ipv6Net, TypeError>;
740
+ /**
741
+ * Creates an instance of {@link Ipv6Net} from a string representation.
742
+ * @param value The string representation of the IPv6 network, e.g., `2001:db8::/64` or full interface address with size.
743
+ * @returns An instance of {@link Ipv6Net}.
744
+ * @throws {TypeError} If the input string is not a valid IPv6 network representation.
745
+ * @since v0.2.0
746
+ */
747
+ static fromOrThrow(value: string): Ipv6Net;
748
+ /**
749
+ * Checks if the given IPv6 address is contained within the network.
750
+ * @param addr The {@link Ipv6Addr} to check.
751
+ * @returns `true` if the given address is contained within the network, otherwise `false`.
752
+ * @since v0.2.0
753
+ */
754
+ contains(addr: Ipv6Addr): boolean;
755
+ /**
756
+ * Gets the network mask of the IPv6 network.
757
+ * @returns The network mask as an {@link Ipv6Addr} instance.
758
+ * @since v0.2.0
759
+ */
760
+ netmask(): Ipv6Addr;
761
+ /**
762
+ * Gets the string representation of the IPv6 network.
763
+ * @returns The IPv6 network as a string, e.g., `2001:db8::1/64`.
764
+ * @since v0.2.0
765
+ */
766
+ toString(): string;
767
+ /**
768
+ * Returns the expanded string representation of the IPv6 network.
769
+ * @returns The IPv6 network in expanded notation, e.g., `2001:0db8:0000:0000:0000:0000:0000:0001/64`.
770
+ * @since v0.2.0
771
+ */
772
+ toExpandedString(): string;
773
+ /**
774
+ * Gets the first address within the network.
775
+ * @returns The first address as an {@link Ipv6Addr} instance.
776
+ * @since v0.2.0
777
+ */
778
+ first(): Ipv6Addr;
779
+ /**
780
+ * Gets the last address within the network.
781
+ * @returns The last address as an {@link Ipv6Addr} instance.
782
+ * @since v0.2.0
783
+ */
784
+ last(): Ipv6Addr;
785
+ /**
786
+ * Gets the first usable address within the network.
787
+ * @returns The first usable address as an {@link Ipv6Addr} instance.
788
+ * @since v0.2.0
789
+ */
790
+ firstUsable(): Ipv6Addr;
791
+ /**
792
+ * Gets the last usable address within the network.
793
+ * @returns The last usable address as an {@link Ipv6Addr} instance.
794
+ * @since v0.2.0
795
+ */
796
+ lastUsable(): Ipv6Addr;
797
+ /**
798
+ * Checks if the current network is equal to another network.
799
+ * @param other The other network to compare with.
800
+ * @returns `true` if the networks are equal, otherwise `false`.
801
+ * @since v0.2.0
802
+ */
803
+ equals(other?: unknown): boolean;
804
+ /**
805
+ * Assigns an address to the current network, effectively combining the network with the given address.
806
+ * @param value The other IPv6 address to combine with (e.g., `::100`)
807
+ * @returns The combined IPv6 address as a {@link CoreResult} containing either the resulting {@link Ipv6Addr} or a {@link RangeError} if the address does not fit within the host portion of the network.
808
+ * @since v0.2.0
809
+ */
810
+ assignAddress(value: Ipv6Addr | string): CoreResult<Ipv6Addr, RangeError>;
811
+ /**
812
+ * Assigns an address to the current network, effectively combining the network with the given address.
813
+ * @param other The other IPv6 address to combine with (e.g., `::100`)
814
+ * @returns The combined IPv6 address as an {@link Ipv6Addr} instance. (e.g., combining `2001:db8::/64` with `::100` would result in `2001:db8::100`)
815
+ * @throws {RangeError} If the given address does not fit within the host portion of the network.
816
+ * @since v0.2.0
817
+ */
818
+ assignAddressOrThrow(other: Ipv6Addr | string): Ipv6Addr;
819
+ /**
820
+ * Checks if the current network is a subnet of the given parent network.
821
+ * @param parent The parent network to check against.
822
+ * @returns `true` if the current network is a subnet of the parent network, `false` otherwise.
823
+ * @since v0.2.0
824
+ */
825
+ isSubnetOf(parent: Ipv6Net): boolean;
826
+ /**
827
+ * Checks if the current network contains the given child network.
828
+ * @param child The child network to check for containment.
829
+ * @returns `true` if the current network contains the child network, `false` otherwise.
830
+ * @since v0.2.0
831
+ */
832
+ containsNet(child: Ipv6Net): boolean;
833
+ /**
834
+ * Gets an iterable of all addresses within the network.
835
+ * @returns An {@link Ipv6Addr} {@link Iterable} of all addresses within the network.
836
+ * @since v0.2.0
837
+ */
838
+ addresses(): Iterable<Ipv6Addr>;
839
+ /**
840
+ * Gets an iterable of all usable host addresses within the network.
841
+ * @returns An {@link Ipv6Addr} {@link Iterable} of all usable host addresses within the network.
842
+ * @since v0.2.0
843
+ */
844
+ hosts(): Iterable<Ipv6Addr>;
392
845
  }
393
846
  //#endregion
394
- export { Ipv4Addr, Ipv6Addr };
395
847
  //# sourceMappingURL=index.d.cts.map