lisette-stdlib 0.1.13

Little language inspired by Rust that compiles to Go
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
// Generated by Lisette bindgen
// Source: net (Go stdlib)
// Go: 1.25.5
// Lisette: 0.1.12

import "go:context"
import "go:io"
import "go:net/netip"
import "go:os"
import "go:syscall"
import "go:time"

pub fn CIDRMask(ones: int, bits: int) -> IPMask

/// Dial connects to the address on the named network.
/// 
/// Known networks are "tcp", "tcp4" (IPv4-only), "tcp6" (IPv6-only),
/// "udp", "udp4" (IPv4-only), "udp6" (IPv6-only), "ip", "ip4"
/// (IPv4-only), "ip6" (IPv6-only), "unix", "unixgram" and
/// "unixpacket".
/// 
/// For TCP and UDP networks, the address has the form "host:port".
/// The host must be a literal IP address, or a host name that can be
/// resolved to IP addresses.
/// The port must be a literal port number or a service name.
/// If the host is a literal IPv6 address it must be enclosed in square
/// brackets, as in "[2001:db8::1]:80" or "[fe80::1%zone]:80".
/// The zone specifies the scope of the literal IPv6 address as defined
/// in RFC 4007.
/// The functions [JoinHostPort] and [SplitHostPort] manipulate a pair of
/// host and port in this form.
/// When using TCP, and the host resolves to multiple IP addresses,
/// Dial will try each IP address in order until one succeeds.
/// 
/// Examples:
/// 
/// 	Dial("tcp", "golang.org:http")
/// 	Dial("tcp", "192.0.2.1:http")
/// 	Dial("tcp", "198.51.100.1:80")
/// 	Dial("udp", "[2001:db8::1]:domain")
/// 	Dial("udp", "[fe80::1%lo0]:53")
/// 	Dial("tcp", ":80")
/// 
/// For IP networks, the network must be "ip", "ip4" or "ip6" followed
/// by a colon and a literal protocol number or a protocol name, and
/// the address has the form "host". The host must be a literal IP
/// address or a literal IPv6 address with zone.
/// It depends on each operating system how the operating system
/// behaves with a non-well known protocol number such as "0" or "255".
/// 
/// Examples:
/// 
/// 	Dial("ip4:1", "192.0.2.1")
/// 	Dial("ip6:ipv6-icmp", "2001:db8::1")
/// 	Dial("ip6:58", "fe80::1%lo0")
/// 
/// For TCP, UDP and IP networks, if the host is empty or a literal
/// unspecified IP address, as in ":80", "0.0.0.0:80" or "[::]:80" for
/// TCP and UDP, "", "0.0.0.0" or "::" for IP, the local system is
/// assumed.
/// 
/// For Unix networks, the address must be a file system path.
pub fn Dial(network: string, address: string) -> Result<Conn, error>

/// DialIP acts like [Dial] for IP networks.
/// 
/// The network must be an IP network name; see func Dial for details.
/// 
/// If laddr is nil, a local address is automatically chosen.
/// If the IP field of raddr is nil or an unspecified IP address, the
/// local system is assumed.
pub fn DialIP(network: string, laddr: Ref<IPAddr>, raddr: Ref<IPAddr>) -> Result<Ref<IPConn>, error>

/// DialTCP acts like [Dial] for TCP networks.
/// 
/// The network must be a TCP network name; see func Dial for details.
/// 
/// If laddr is nil, a local address is automatically chosen.
/// If the IP field of raddr is nil or an unspecified IP address, the
/// local system is assumed.
pub fn DialTCP(network: string, laddr: Ref<TCPAddr>, raddr: Ref<TCPAddr>) -> Result<Ref<TCPConn>, error>

/// DialTimeout acts like [Dial] but takes a timeout.
/// 
/// The timeout includes name resolution, if required.
/// When using TCP, and the host in the address parameter resolves to
/// multiple IP addresses, the timeout is spread over each consecutive
/// dial, such that each is given an appropriate fraction of the time
/// to connect.
/// 
/// See func Dial for a description of the network and address
/// parameters.
pub fn DialTimeout(network: string, address: string, timeout: time.Duration) -> Result<Conn, error>

/// DialUDP acts like [Dial] for UDP networks.
/// 
/// The network must be a UDP network name; see func [Dial] for details.
/// 
/// If laddr is nil, a local address is automatically chosen.
/// If the IP field of raddr is nil or an unspecified IP address, the
/// local system is assumed.
pub fn DialUDP(network: string, laddr: Ref<UDPAddr>, raddr: Ref<UDPAddr>) -> Result<Ref<UDPConn>, error>

/// DialUnix acts like [Dial] for Unix networks.
/// 
/// The network must be a Unix network name; see func [Dial] for details.
/// 
/// If laddr is non-nil, it is used as the local address for the
/// connection.
pub fn DialUnix(network: string, laddr: Ref<UnixAddr>, raddr: Ref<UnixAddr>) -> Result<Ref<UnixConn>, error>

/// FileConn returns a copy of the network connection corresponding to
/// the open file f.
/// It is the caller's responsibility to close f when finished.
/// Closing c does not affect f, and closing f does not affect c.
pub fn FileConn(f: Ref<os.File>) -> Result<Conn, error>

/// FileListener returns a copy of the network listener corresponding
/// to the open file f.
/// It is the caller's responsibility to close ln when finished.
/// Closing ln does not affect f, and closing f does not affect ln.
pub fn FileListener(f: Ref<os.File>) -> Result<Listener, error>

/// FilePacketConn returns a copy of the packet network connection
/// corresponding to the open file f.
/// It is the caller's responsibility to close f when finished.
/// Closing c does not affect f, and closing f does not affect c.
pub fn FilePacketConn(f: Ref<os.File>) -> Result<PacketConn, error>

pub fn IPv4(a: uint8, b: uint8, c: uint8, d: uint8) -> IP

pub fn IPv4Mask(a: uint8, b: uint8, c: uint8, d: uint8) -> IPMask

/// InterfaceAddrs returns a list of the system's unicast interface
/// addresses.
/// 
/// The returned list does not identify the associated interface; use
/// Interfaces and [Interface.Addrs] for more detail.
pub fn InterfaceAddrs() -> Result<Slice<Addr>, error>

/// InterfaceByIndex returns the interface specified by index.
/// 
/// On Solaris, it returns one of the logical network interfaces
/// sharing the logical data link; for more precision use
/// [InterfaceByName].
pub fn InterfaceByIndex(index: int) -> Result<Ref<Interface>, error>

/// InterfaceByName returns the interface specified by name.
pub fn InterfaceByName(name: string) -> Result<Ref<Interface>, error>

/// Interfaces returns a list of the system's network interfaces.
pub fn Interfaces() -> Result<Slice<Interface>, error>

/// JoinHostPort combines host and port into a network address of the
/// form "host:port". If host contains a colon, as found in literal
/// IPv6 addresses, then JoinHostPort returns "[host]:port".
/// 
/// See func Dial for a description of the host and port parameters.
pub fn JoinHostPort(host: string, port: string) -> string

/// Listen announces on the local network address.
/// 
/// The network must be "tcp", "tcp4", "tcp6", "unix" or "unixpacket".
/// 
/// For TCP networks, if the host in the address parameter is empty or
/// a literal unspecified IP address, Listen listens on all available
/// unicast and anycast IP addresses of the local system.
/// To only use IPv4, use network "tcp4".
/// The address can use a host name, but this is not recommended,
/// because it will create a listener for at most one of the host's IP
/// addresses.
/// If the port in the address parameter is empty or "0", as in
/// "127.0.0.1:" or "[::1]:0", a port number is automatically chosen.
/// The [Addr] method of [Listener] can be used to discover the chosen
/// port.
/// 
/// See func [Dial] for a description of the network and address
/// parameters.
/// 
/// Listen uses context.Background internally; to specify the context, use
/// [ListenConfig.Listen].
pub fn Listen(network: string, address: string) -> Result<Listener, error>

/// ListenIP acts like [ListenPacket] for IP networks.
/// 
/// The network must be an IP network name; see func Dial for details.
/// 
/// If the IP field of laddr is nil or an unspecified IP address,
/// ListenIP listens on all available IP addresses of the local system
/// except multicast IP addresses.
pub fn ListenIP(network: string, laddr: Ref<IPAddr>) -> Result<Ref<IPConn>, error>

/// ListenMulticastUDP acts like [ListenPacket] for UDP networks but
/// takes a group address on a specific network interface.
/// 
/// The network must be a UDP network name; see func [Dial] for details.
/// 
/// ListenMulticastUDP listens on all available IP addresses of the
/// local system including the group, multicast IP address.
/// If ifi is nil, ListenMulticastUDP uses the system-assigned
/// multicast interface, although this is not recommended because the
/// assignment depends on platforms and sometimes it might require
/// routing configuration.
/// If the Port field of gaddr is 0, a port number is automatically
/// chosen.
/// 
/// ListenMulticastUDP is just for convenience of simple, small
/// applications. There are [golang.org/x/net/ipv4] and
/// [golang.org/x/net/ipv6] packages for general purpose uses.
/// 
/// Note that ListenMulticastUDP will set the IP_MULTICAST_LOOP socket option
/// to 0 under IPPROTO_IP, to disable loopback of multicast packets.
pub fn ListenMulticastUDP(
  network: string,
  ifi: Ref<Interface>,
  gaddr: Ref<UDPAddr>,
) -> Result<Ref<UDPConn>, error>

/// ListenPacket announces on the local network address.
/// 
/// The network must be "udp", "udp4", "udp6", "unixgram", or an IP
/// transport. The IP transports are "ip", "ip4", or "ip6" followed by
/// a colon and a literal protocol number or a protocol name, as in
/// "ip:1" or "ip:icmp".
/// 
/// For UDP and IP networks, if the host in the address parameter is
/// empty or a literal unspecified IP address, ListenPacket listens on
/// all available IP addresses of the local system except multicast IP
/// addresses.
/// To only use IPv4, use network "udp4" or "ip4:proto".
/// The address can use a host name, but this is not recommended,
/// because it will create a listener for at most one of the host's IP
/// addresses.
/// If the port in the address parameter is empty or "0", as in
/// "127.0.0.1:" or "[::1]:0", a port number is automatically chosen.
/// The LocalAddr method of [PacketConn] can be used to discover the
/// chosen port.
/// 
/// See func [Dial] for a description of the network and address
/// parameters.
/// 
/// ListenPacket uses context.Background internally; to specify the context, use
/// [ListenConfig.ListenPacket].
pub fn ListenPacket(network: string, address: string) -> Result<PacketConn, error>

/// ListenTCP acts like [Listen] for TCP networks.
/// 
/// The network must be a TCP network name; see func Dial for details.
/// 
/// If the IP field of laddr is nil or an unspecified IP address,
/// ListenTCP listens on all available unicast and anycast IP addresses
/// of the local system.
/// If the Port field of laddr is 0, a port number is automatically
/// chosen.
pub fn ListenTCP(network: string, laddr: Ref<TCPAddr>) -> Result<Ref<TCPListener>, error>

/// ListenUDP acts like [ListenPacket] for UDP networks.
/// 
/// The network must be a UDP network name; see func [Dial] for details.
/// 
/// If the IP field of laddr is nil or an unspecified IP address,
/// ListenUDP listens on all available IP addresses of the local system
/// except multicast IP addresses.
/// If the Port field of laddr is 0, a port number is automatically
/// chosen.
pub fn ListenUDP(network: string, laddr: Ref<UDPAddr>) -> Result<Ref<UDPConn>, error>

/// ListenUnix acts like [Listen] for Unix networks.
/// 
/// The network must be "unix" or "unixpacket".
pub fn ListenUnix(network: string, laddr: Ref<UnixAddr>) -> Result<Ref<UnixListener>, error>

/// ListenUnixgram acts like [ListenPacket] for Unix networks.
/// 
/// The network must be "unixgram".
pub fn ListenUnixgram(network: string, laddr: Ref<UnixAddr>) -> Result<Ref<UnixConn>, error>

/// LookupAddr performs a reverse lookup for the given address, returning a list
/// of names mapping to that address.
/// 
/// The returned names are validated to be properly formatted presentation-format
/// domain names. If the response contains invalid names, those records are filtered
/// out and an error will be returned alongside the remaining results, if any.
/// 
/// When using the host C library resolver, at most one result will be
/// returned. To bypass the host resolver, use a custom [Resolver].
/// 
/// LookupAddr uses [context.Background] internally; to specify the context, use
/// [Resolver.LookupAddr].
pub fn LookupAddr(addr: string) -> Result<Slice<string>, error>

/// LookupCNAME returns the canonical name for the given host.
/// Callers that do not care about the canonical name can call
/// [LookupHost] or [LookupIP] directly; both take care of resolving
/// the canonical name as part of the lookup.
/// 
/// A canonical name is the final name after following zero
/// or more CNAME records.
/// LookupCNAME does not return an error if host does not
/// contain DNS "CNAME" records, as long as host resolves to
/// address records.
/// 
/// The returned canonical name is validated to be a properly
/// formatted presentation-format domain name.
/// 
/// LookupCNAME uses [context.Background] internally; to specify the context, use
/// [Resolver.LookupCNAME].
pub fn LookupCNAME(host: string) -> Result<string, error>

/// LookupHost looks up the given host using the local resolver.
/// It returns a slice of that host's addresses.
/// 
/// LookupHost uses [context.Background] internally; to specify the context, use
/// [Resolver.LookupHost].
pub fn LookupHost(host: string) -> Result<Slice<string>, error>

/// LookupIP looks up host using the local resolver.
/// It returns a slice of that host's IPv4 and IPv6 addresses.
pub fn LookupIP(host: string) -> Result<Slice<IP>, error>

/// LookupMX returns the DNS MX records for the given domain name sorted by preference.
/// 
/// The returned mail server names are validated to be properly
/// formatted presentation-format domain names, or numeric IP addresses.
/// If the response contains invalid names, those records are filtered out
/// and an error will be returned alongside the remaining results, if any.
/// 
/// LookupMX uses [context.Background] internally; to specify the context, use
/// [Resolver.LookupMX].
pub fn LookupMX(name: string) -> Result<Slice<Ref<MX>>, error>

/// LookupNS returns the DNS NS records for the given domain name.
/// 
/// The returned name server names are validated to be properly
/// formatted presentation-format domain names. If the response contains
/// invalid names, those records are filtered out and an error
/// will be returned alongside the remaining results, if any.
/// 
/// LookupNS uses [context.Background] internally; to specify the context, use
/// [Resolver.LookupNS].
pub fn LookupNS(name: string) -> Result<Slice<Ref<NS>>, error>

/// LookupPort looks up the port for the given network and service.
/// 
/// LookupPort uses [context.Background] internally; to specify the context, use
/// [Resolver.LookupPort].
pub fn LookupPort(network: string, service: string) -> Result<int, error>

/// LookupSRV tries to resolve an [SRV] query of the given service,
/// protocol, and domain name. The proto is "tcp" or "udp".
/// The returned records are sorted by priority and randomized
/// by weight within a priority.
/// 
/// LookupSRV constructs the DNS name to look up following RFC 2782.
/// That is, it looks up _service._proto.name. To accommodate services
/// publishing SRV records under non-standard names, if both service
/// and proto are empty strings, LookupSRV looks up name directly.
/// 
/// The returned service names are validated to be properly
/// formatted presentation-format domain names. If the response contains
/// invalid names, those records are filtered out and an error
/// will be returned alongside the remaining results, if any.
pub fn LookupSRV(service: string, proto: string, name: string) -> Result<(string, Slice<Ref<SRV>>), error>

/// LookupTXT returns the DNS TXT records for the given domain name.
/// 
/// If a DNS TXT record holds multiple strings, they are concatenated as a
/// single string.
/// 
/// LookupTXT uses [context.Background] internally; to specify the context, use
/// [Resolver.LookupTXT].
pub fn LookupTXT(name: string) -> Result<Slice<string>, error>

/// ParseCIDR parses s as a CIDR notation IP address and prefix length,
/// like "192.0.2.0/24" or "2001:db8::/32", as defined in
/// RFC 4632 and RFC 4291.
/// 
/// It returns the IP address and the network implied by the IP and
/// prefix length.
/// For example, ParseCIDR("192.0.2.1/24") returns the IP address
/// 192.0.2.1 and the network 192.0.2.0/24.
pub fn ParseCIDR(s: string) -> Result<(IP, Ref<IPNet>), error>

pub fn ParseIP(s: string) -> IP

/// ParseMAC parses s as an IEEE 802 MAC-48, EUI-48, EUI-64, or a 20-octet
/// IP over InfiniBand link-layer address using one of the following formats:
/// 
/// 	00:00:5e:00:53:01
/// 	02:00:5e:10:00:00:00:01
/// 	00:00:00:00:fe:80:00:00:00:00:00:00:02:00:5e:10:00:00:00:01
/// 	00-00-5e-00-53-01
/// 	02-00-5e-10-00-00-00-01
/// 	00-00-00-00-fe-80-00-00-00-00-00-00-02-00-5e-10-00-00-00-01
/// 	0000.5e00.5301
/// 	0200.5e10.0000.0001
/// 	0000.0000.fe80.0000.0000.0000.0200.5e10.0000.0001
pub fn ParseMAC(s: string) -> Result<HardwareAddr, error>

/// Pipe creates a synchronous, in-memory, full duplex
/// network connection; both ends implement the [Conn] interface.
/// Reads on one end are matched with writes on the other,
/// copying data directly between the two; there is no internal
/// buffering.
pub fn Pipe() -> (Conn, Conn)

/// ResolveIPAddr returns an address of IP end point.
/// 
/// The network must be an IP network name.
/// 
/// If the host in the address parameter is not a literal IP address,
/// ResolveIPAddr resolves the address to an address of IP end point.
/// Otherwise, it parses the address as a literal IP address.
/// The address parameter can use a host name, but this is not
/// recommended, because it will return at most one of the host name's
/// IP addresses.
/// 
/// See func [Dial] for a description of the network and address
/// parameters.
pub fn ResolveIPAddr(network: string, address: string) -> Result<Ref<IPAddr>, error>

/// ResolveTCPAddr returns an address of TCP end point.
/// 
/// The network must be a TCP network name.
/// 
/// If the host in the address parameter is not a literal IP address or
/// the port is not a literal port number, ResolveTCPAddr resolves the
/// address to an address of TCP end point.
/// Otherwise, it parses the address as a pair of literal IP address
/// and port number.
/// The address parameter can use a host name, but this is not
/// recommended, because it will return at most one of the host name's
/// IP addresses.
/// 
/// See func [Dial] for a description of the network and address
/// parameters.
pub fn ResolveTCPAddr(network: string, address: string) -> Result<Ref<TCPAddr>, error>

/// ResolveUDPAddr returns an address of UDP end point.
/// 
/// The network must be a UDP network name.
/// 
/// If the host in the address parameter is not a literal IP address or
/// the port is not a literal port number, ResolveUDPAddr resolves the
/// address to an address of UDP end point.
/// Otherwise, it parses the address as a pair of literal IP address
/// and port number.
/// The address parameter can use a host name, but this is not
/// recommended, because it will return at most one of the host name's
/// IP addresses.
/// 
/// See func [Dial] for a description of the network and address
/// parameters.
pub fn ResolveUDPAddr(network: string, address: string) -> Result<Ref<UDPAddr>, error>

/// ResolveUnixAddr returns an address of Unix domain socket end point.
/// 
/// The network must be a Unix network name.
/// 
/// See func [Dial] for a description of the network and address
/// parameters.
pub fn ResolveUnixAddr(network: string, address: string) -> Result<Ref<UnixAddr>, error>

/// SplitHostPort splits a network address of the form "host:port",
/// "host%zone:port", "[host]:port" or "[host%zone]:port" into host or
/// host%zone and port.
/// 
/// A literal IPv6 address in hostport must be enclosed in square
/// brackets, as in "[::1]:80", "[::1%lo0]:80".
/// 
/// See func Dial for a description of the hostport parameter, and host
/// and port results.
pub fn SplitHostPort(hostport: string) -> Result<(string, string), error>

pub fn TCPAddrFromAddrPort(addr: netip.AddrPort) -> Ref<TCPAddr>

pub fn UDPAddrFromAddrPort(addr: netip.AddrPort) -> Ref<UDPAddr>

/// Addr represents a network end point address.
/// 
/// The two methods [Addr.Network] and [Addr.String] conventionally return strings
/// that can be passed as the arguments to [Dial], but the exact form
/// and meaning of the strings is up to the implementation.
pub interface Addr {
  fn Network() -> string
  fn String() -> string
}

pub struct AddrError {
  pub Err: string,
  pub Addr: string,
}

/// Buffers contains zero or more runs of bytes to write.
/// 
/// On certain machines, for certain types of connections, this is
/// optimized into an OS-specific batch write operation (such as
/// "writev").
pub struct Buffers(Slice<Slice<uint8>>)

/// Conn is a generic stream-oriented network connection.
/// 
/// Multiple goroutines may invoke methods on a Conn simultaneously.
pub interface Conn {
  fn Close() -> Result<(), error>
  fn LocalAddr() -> Addr
  fn Read(mut b: Slice<uint8>) -> Partial<int, error>
  fn RemoteAddr() -> Addr
  fn SetDeadline(t: time.Time) -> Result<(), error>
  fn SetReadDeadline(t: time.Time) -> Result<(), error>
  fn SetWriteDeadline(t: time.Time) -> Result<(), error>
  fn Write(b: Slice<uint8>) -> Partial<int, error>
}

/// DNSConfigError represents an error reading the machine's DNS configuration.
/// (No longer used; kept for compatibility.)
pub struct DNSConfigError {
  pub Err: error,
}

/// DNSError represents a DNS lookup error.
pub struct DNSError {
  pub UnwrapErr: error,
  pub Err: string,
  pub Name: string,
  pub Server: string,
  pub IsTimeout: bool,
  pub IsTemporary: bool,
  pub IsNotFound: bool,
}

/// A Dialer contains options for connecting to an address.
/// 
/// The zero value for each field is equivalent to dialing
/// without that option. Dialing with the zero value of Dialer
/// is therefore equivalent to just calling the [Dial] function.
/// 
/// It is safe to call Dialer's methods concurrently.
pub struct Dialer {
  pub Timeout: time.Duration,
  pub Deadline: time.Time,
  pub LocalAddr: Option<Addr>,
  pub DualStack: bool,
  pub FallbackDelay: time.Duration,
  pub KeepAlive: time.Duration,
  pub KeepAliveConfig: KeepAliveConfig,
  pub Resolver: Option<Ref<Resolver>>,
  pub Cancel: Receiver<()>,
  pub Control: fn(string, string, syscall.RawConn) -> Result<(), error>,
  pub ControlContext: fn(context.Context, string, string, syscall.RawConn) -> Result<(), error>,
}

/// An Error represents a network error.
pub interface Error {
  fn Error() -> string
  fn Temporary() -> bool
  fn Timeout() -> bool
}

pub struct Flags(uint)

/// A HardwareAddr represents a physical hardware address.
pub struct HardwareAddr(Slice<uint8>)

/// An IP is a single IP address, a slice of bytes.
/// Functions in this package accept either 4-byte (IPv4)
/// or 16-byte (IPv6) slices as input.
/// 
/// Note that in this documentation, referring to an
/// IP address as an IPv4 address or an IPv6 address
/// is a semantic property of the address, not just the
/// length of the byte slice: a 16-byte slice can still
/// be an IPv4 address.
pub struct IP(Slice<uint8>)

/// IPAddr represents the address of an IP end point.
pub struct IPAddr {
  pub IP: IP,
  pub Zone: string,
}

/// IPConn is the implementation of the [Conn] and [PacketConn] interfaces
/// for IP network connections.
pub type IPConn

/// An IPMask is a bitmask that can be used to manipulate
/// IP addresses for IP addressing and routing.
/// 
/// See type [IPNet] and func [ParseCIDR] for details.
pub struct IPMask(Slice<uint8>)

/// An IPNet represents an IP network.
pub struct IPNet {
  pub IP: IP,
  pub Mask: IPMask,
}

/// Interface represents a mapping between network interface name
/// and index. It also represents network interface facility
/// information.
pub struct Interface {
  pub Index: int,
  pub MTU: int,
  pub Name: string,
  pub HardwareAddr: HardwareAddr,
  pub Flags: Flags,
}

pub struct InvalidAddrError(string)

/// KeepAliveConfig contains TCP keep-alive options.
/// 
/// If the Idle, Interval, or Count fields are zero, a default value is chosen.
/// If a field is negative, the corresponding socket-level option will be left unchanged.
/// 
/// Note that prior to Windows 10 version 1709, neither setting Idle and Interval
/// separately nor changing Count (which is usually 10) is supported.
/// Therefore, it's recommended to set both Idle and Interval to non-negative values
/// in conjunction with a -1 for Count on those old Windows if you intend to customize
/// the TCP keep-alive settings.
/// By contrast, if only one of Idle and Interval is set to a non-negative value,
/// the other will be set to the system default value, and ultimately,
/// set both Idle and Interval to negative values if you want to leave them unchanged.
/// 
/// Note that Solaris and its derivatives do not support setting Interval to a non-negative value
/// and Count to a negative value, or vice-versa.
pub struct KeepAliveConfig {
  pub Enable: bool,
  pub Idle: time.Duration,
  pub Interval: time.Duration,
  pub Count: int,
}

/// ListenConfig contains options for listening to an address.
pub struct ListenConfig {
  pub Control: fn(string, string, syscall.RawConn) -> Result<(), error>,
  pub KeepAlive: time.Duration,
  pub KeepAliveConfig: KeepAliveConfig,
}

/// A Listener is a generic network listener for stream-oriented protocols.
/// 
/// Multiple goroutines may invoke methods on a Listener simultaneously.
pub interface Listener {
  fn Accept() -> Result<Conn, error>
  fn Addr() -> Addr
  fn Close() -> Result<(), error>
}

/// An MX represents a single DNS MX record.
pub struct MX {
  pub Host: string,
  pub Pref: uint16,
}

/// An NS represents a single DNS NS record.
pub struct NS {
  pub Host: string,
}

/// OpError is the error type usually returned by functions in the net
/// package. It describes the operation, network type, and address of
/// an error.
pub struct OpError {
  pub Op: string,
  pub Net: string,
  pub Source: Option<Addr>,
  pub Addr: Option<Addr>,
  pub Err: error,
}

/// PacketConn is a generic packet-oriented network connection.
/// 
/// Multiple goroutines may invoke methods on a PacketConn simultaneously.
pub interface PacketConn {
  fn Close() -> Result<(), error>
  fn LocalAddr() -> Addr
  fn ReadFrom(mut p: Slice<uint8>) -> Result<(int, Addr), error>
  fn SetDeadline(t: time.Time) -> Result<(), error>
  fn SetReadDeadline(t: time.Time) -> Result<(), error>
  fn SetWriteDeadline(t: time.Time) -> Result<(), error>
  fn WriteTo(p: Slice<uint8>, addr: Addr) -> Result<int, error>
}

/// A ParseError is the error type of literal network address parsers.
pub struct ParseError {
  pub Type: string,
  pub Text: string,
}

/// A Resolver looks up names and numbers.
/// 
/// A nil *Resolver is equivalent to a zero Resolver.
pub struct Resolver {
  pub PreferGo: bool,
  pub StrictErrors: bool,
  pub Dial: fn(context.Context, string, string) -> Result<Conn, error>,
}

/// An SRV represents a single DNS SRV record.
pub struct SRV {
  pub Target: string,
  pub Port: uint16,
  pub Priority: uint16,
  pub Weight: uint16,
}

/// TCPAddr represents the address of a TCP end point.
pub struct TCPAddr {
  pub IP: IP,
  pub Port: int,
  pub Zone: string,
}

/// TCPConn is an implementation of the [Conn] interface for TCP network
/// connections.
pub type TCPConn

/// TCPListener is a TCP network listener. Clients should typically
/// use variables of type [Listener] instead of assuming TCP.
pub type TCPListener

/// UDPAddr represents the address of a UDP end point.
pub struct UDPAddr {
  pub IP: IP,
  pub Port: int,
  pub Zone: string,
}

/// UDPConn is the implementation of the [Conn] and [PacketConn] interfaces
/// for UDP network connections.
pub type UDPConn

/// UnixAddr represents the address of a Unix domain socket end point.
pub struct UnixAddr {
  pub Name: string,
  pub Net: string,
}

/// UnixConn is an implementation of the [Conn] interface for connections
/// to Unix domain sockets.
pub type UnixConn

/// UnixListener is a Unix domain socket listener. Clients should
/// typically use variables of type [Listener] instead of assuming Unix
/// domain sockets.
pub type UnixListener

pub struct UnknownNetworkError(string)

const FlagBroadcast: Flags = 2

const FlagLoopback: Flags = 4

const FlagMulticast: Flags = 16

const FlagPointToPoint: Flags = 8

const FlagRunning: Flags = 32

const FlagUp: Flags = 1

/// IP address lengths (bytes).
const IPv4len = 4

/// IP address lengths (bytes).
const IPv6len = 16

/// DefaultResolver is the resolver used by the package-level Lookup
/// functions and by Dialers without a specified Resolver.
pub var DefaultResolver: Ref<Resolver>

/// ErrClosed is the error returned by an I/O call on a network
/// connection that has already been closed, or that is closed by
/// another goroutine before the I/O is completed. This may be wrapped
/// in another error, and should normally be tested using
/// errors.Is(err, net.ErrClosed).
pub var ErrClosed: error

/// Various errors contained in OpError.
pub var ErrWriteToConnected: error

/// Well-known IPv4 addresses
pub var IPv4allrouter: IP

/// Well-known IPv4 addresses
pub var IPv4allsys: IP

/// Well-known IPv4 addresses
pub var IPv4bcast: IP

/// Well-known IPv4 addresses
pub var IPv4zero: IP

/// Well-known IPv6 addresses
pub var IPv6interfacelocalallnodes: IP

/// Well-known IPv6 addresses
pub var IPv6linklocalallnodes: IP

/// Well-known IPv6 addresses
pub var IPv6linklocalallrouters: IP

/// Well-known IPv6 addresses
pub var IPv6loopback: IP

/// Well-known IPv6 addresses
pub var IPv6unspecified: IP

/// Well-known IPv6 addresses
pub var IPv6zero: IP

impl AddrError {
  fn Error(self: Ref<AddrError>) -> string

  fn Temporary(self: Ref<AddrError>) -> bool

  fn Timeout(self: Ref<AddrError>) -> bool
}

impl Buffers {
  /// Read from the buffers.
  /// 
  /// Read implements [io.Reader] for [Buffers].
  /// 
  /// Read modifies the slice v as well as v[i] for 0 <= i < len(v),
  /// but does not modify v[i][j] for any i, j.
  fn Read(self: Ref<Buffers>, mut p: Slice<uint8>) -> Partial<int, error>

  /// WriteTo writes contents of the buffers to w.
  /// 
  /// WriteTo implements [io.WriterTo] for [Buffers].
  /// 
  /// WriteTo modifies the slice v as well as v[i] for 0 <= i < len(v),
  /// but does not modify v[i][j] for any i, j.
  fn WriteTo(self: Ref<Buffers>, w: io.Writer) -> Result<int64, error>
}

impl DNSConfigError {
  fn Error(self: Ref<DNSConfigError>) -> string

  fn Temporary(self: Ref<DNSConfigError>) -> bool

  fn Timeout(self: Ref<DNSConfigError>) -> bool

  fn Unwrap(self: Ref<DNSConfigError>) -> Option<error>
}

impl DNSError {
  fn Error(self: Ref<DNSError>) -> string

  /// Temporary reports whether the DNS error is known to be temporary.
  /// This is not always known; a DNS lookup may fail due to a temporary
  /// error and return a [DNSError] for which Temporary returns false.
  fn Temporary(self: Ref<DNSError>) -> bool

  /// Timeout reports whether the DNS lookup is known to have timed out.
  /// This is not always known; a DNS lookup may fail due to a timeout
  /// and return a [DNSError] for which Timeout returns false.
  fn Timeout(self: Ref<DNSError>) -> bool

  /// Unwrap returns e.UnwrapErr.
  fn Unwrap(self: Ref<DNSError>) -> Option<error>
}

impl Dialer {
  /// Dial connects to the address on the named network.
  /// 
  /// See func Dial for a description of the network and address
  /// parameters.
  /// 
  /// Dial uses [context.Background] internally; to specify the context, use
  /// [Dialer.DialContext].
  fn Dial(self: Ref<Dialer>, network: string, address: string) -> Result<Conn, error>

  /// DialContext connects to the address on the named network using
  /// the provided context.
  /// 
  /// The provided Context must be non-nil. If the context expires before
  /// the connection is complete, an error is returned. Once successfully
  /// connected, any expiration of the context will not affect the
  /// connection.
  /// 
  /// When using TCP, and the host in the address parameter resolves to multiple
  /// network addresses, any dial timeout (from d.Timeout or ctx) is spread
  /// over each consecutive dial, such that each is given an appropriate
  /// fraction of the time to connect.
  /// For example, if a host has 4 IP addresses and the timeout is 1 minute,
  /// the connect to each single address will be given 15 seconds to complete
  /// before trying the next one.
  /// 
  /// See func [Dial] for a description of the network and address
  /// parameters.
  fn DialContext(
    self: Ref<Dialer>,
    ctx: context.Context,
    network: string,
    address: string,
  ) -> Result<Conn, error>

  /// MultipathTCP reports whether MPTCP will be used.
  /// 
  /// This method doesn't check if MPTCP is supported by the operating
  /// system or not.
  fn MultipathTCP(self: Ref<Dialer>) -> bool

  /// SetMultipathTCP directs the [Dial] methods to use, or not use, MPTCP,
  /// if supported by the operating system. This method overrides the
  /// system default and the GODEBUG=multipathtcp=... setting if any.
  /// 
  /// If MPTCP is not available on the host or not supported by the server,
  /// the Dial methods will fall back to TCP.
  fn SetMultipathTCP(self: Ref<Dialer>, use: bool)
}

impl Flags {
  fn String(self) -> string
}

impl HardwareAddr {
  fn String(self) -> string
}

impl IP {
  /// AppendText implements the [encoding.TextAppender] interface.
  /// The encoding is the same as returned by [IP.String], with one exception:
  /// When len(ip) is zero, it appends nothing.
  fn AppendText(self, mut b: Slice<uint8>) -> Result<Slice<uint8>, error>

  /// DefaultMask returns the default IP mask for the IP address ip.
  /// Only IPv4 addresses have default masks; DefaultMask returns
  /// nil if ip is not a valid IPv4 address.
  fn DefaultMask(self) -> IPMask

  /// Equal reports whether ip and x are the same IP address.
  /// An IPv4 address and that same address in IPv6 form are
  /// considered to be equal.
  fn Equal(self, x: IP) -> bool

  /// IsGlobalUnicast reports whether ip is a global unicast
  /// address.
  /// 
  /// The identification of global unicast addresses uses address type
  /// identification as defined in RFC 1122, RFC 4632 and RFC 4291 with
  /// the exception of IPv4 directed broadcast addresses.
  /// It returns true even if ip is in IPv4 private address space or
  /// local IPv6 unicast address space.
  fn IsGlobalUnicast(self) -> bool

  /// IsInterfaceLocalMulticast reports whether ip is
  /// an interface-local multicast address.
  fn IsInterfaceLocalMulticast(self) -> bool

  /// IsLinkLocalMulticast reports whether ip is a link-local
  /// multicast address.
  fn IsLinkLocalMulticast(self) -> bool

  /// IsLinkLocalUnicast reports whether ip is a link-local
  /// unicast address.
  fn IsLinkLocalUnicast(self) -> bool

  /// IsLoopback reports whether ip is a loopback address.
  fn IsLoopback(self) -> bool

  /// IsMulticast reports whether ip is a multicast address.
  fn IsMulticast(self) -> bool

  /// IsPrivate reports whether ip is a private address, according to
  /// RFC 1918 (IPv4 addresses) and RFC 4193 (IPv6 addresses).
  fn IsPrivate(self) -> bool

  /// IsUnspecified reports whether ip is an unspecified address, either
  /// the IPv4 address "0.0.0.0" or the IPv6 address "::".
  fn IsUnspecified(self) -> bool

  /// MarshalText implements the [encoding.TextMarshaler] interface.
  /// The encoding is the same as returned by [IP.String], with one exception:
  /// When len(ip) is zero, it returns an empty slice.
  fn MarshalText(self) -> Result<Slice<uint8>, error>

  /// Mask returns the result of masking the IP address ip with mask.
  fn Mask(self, mask: IPMask) -> IP

  /// String returns the string form of the IP address ip.
  /// It returns one of 4 forms:
  ///   - "<nil>", if ip has length 0
  ///   - dotted decimal ("192.0.2.1"), if ip is an IPv4 or IP4-mapped IPv6 address
  ///   - IPv6 conforming to RFC 5952 ("2001:db8::1"), if ip is a valid IPv6 address
  ///   - the hexadecimal form of ip, without punctuation, if no other cases apply
  fn String(self) -> string

  /// To16 converts the IP address ip to a 16-byte representation.
  /// If ip is not an IP address (it is the wrong length), To16 returns nil.
  fn To16(self) -> IP

  /// To4 converts the IPv4 address ip to a 4-byte representation.
  /// If ip is not an IPv4 address, To4 returns nil.
  fn To4(self) -> IP

  /// UnmarshalText implements the [encoding.TextUnmarshaler] interface.
  /// The IP address is expected in a form accepted by [ParseIP].
  fn UnmarshalText(self: Ref<IP>, text: Slice<uint8>) -> Result<(), error>
}

impl IPAddr {
  /// Network returns the address's network name, "ip".
  fn Network(self: Ref<IPAddr>) -> string

  fn String(self: Ref<IPAddr>) -> string
}

impl IPConn {
  /// Close closes the connection.
  #[allow(unused_result)]
  fn Close(self: Ref<IPConn>) -> Result<(), error>

  /// File returns a copy of the underlying [os.File].
  /// It is the caller's responsibility to close f when finished.
  /// Closing c does not affect f, and closing f does not affect c.
  /// 
  /// The returned os.File's file descriptor is different from the connection's.
  /// Attempting to change properties of the original using this duplicate
  /// may or may not have the desired effect.
  /// 
  /// On Windows, the returned os.File's file descriptor is not usable
  /// on other processes.
  fn File(self: Ref<IPConn>) -> Result<Ref<os.File>, error>

  /// LocalAddr returns the local network address.
  /// The Addr returned is shared by all invocations of LocalAddr, so
  /// do not modify it.
  fn LocalAddr(self: Ref<IPConn>) -> Addr

  /// Read implements the Conn Read method.
  fn Read(self: Ref<IPConn>, mut b: Slice<uint8>) -> Partial<int, error>

  /// ReadFrom implements the [PacketConn] ReadFrom method.
  fn ReadFrom(self: Ref<IPConn>, mut b: Slice<uint8>) -> Result<(int, Addr), error>

  /// ReadFromIP acts like ReadFrom but returns an IPAddr.
  fn ReadFromIP(self: Ref<IPConn>, mut b: Slice<uint8>) -> Result<(int, Ref<IPAddr>), error>

  /// ReadMsgIP reads a message from c, copying the payload into b and
  /// the associated out-of-band data into oob. It returns the number of
  /// bytes copied into b, the number of bytes copied into oob, the flags
  /// that were set on the message and the source address of the message.
  /// 
  /// The packages golang.org/x/net/ipv4 and golang.org/x/net/ipv6 can be
  /// used to manipulate IP-level socket options in oob.
  fn ReadMsgIP(self: Ref<IPConn>, mut b: Slice<uint8>, mut oob: Slice<uint8>) -> Result<(int, int, int, Ref<IPAddr>), error>

  /// RemoteAddr returns the remote network address.
  /// The Addr returned is shared by all invocations of RemoteAddr, so
  /// do not modify it.
  fn RemoteAddr(self: Ref<IPConn>) -> Addr

  /// SetDeadline implements the Conn SetDeadline method.
  fn SetDeadline(self: Ref<IPConn>, t: time.Time) -> Result<(), error>

  /// SetReadBuffer sets the size of the operating system's
  /// receive buffer associated with the connection.
  fn SetReadBuffer(self: Ref<IPConn>, bytes: int) -> Result<(), error>

  /// SetReadDeadline implements the Conn SetReadDeadline method.
  fn SetReadDeadline(self: Ref<IPConn>, t: time.Time) -> Result<(), error>

  /// SetWriteBuffer sets the size of the operating system's
  /// transmit buffer associated with the connection.
  fn SetWriteBuffer(self: Ref<IPConn>, bytes: int) -> Result<(), error>

  /// SetWriteDeadline implements the Conn SetWriteDeadline method.
  fn SetWriteDeadline(self: Ref<IPConn>, t: time.Time) -> Result<(), error>

  /// SyscallConn returns a raw network connection.
  /// This implements the [syscall.Conn] interface.
  fn SyscallConn(self: Ref<IPConn>) -> Result<syscall.RawConn, error>

  /// Write implements the Conn Write method.
  fn Write(self: Ref<IPConn>, b: Slice<uint8>) -> Partial<int, error>

  /// WriteMsgIP writes a message to addr via c, copying the payload from
  /// b and the associated out-of-band data from oob. It returns the
  /// number of payload and out-of-band bytes written.
  /// 
  /// The packages golang.org/x/net/ipv4 and golang.org/x/net/ipv6 can be
  /// used to manipulate IP-level socket options in oob.
  fn WriteMsgIP(
    self: Ref<IPConn>,
    b: Slice<uint8>,
    oob: Slice<uint8>,
    addr: Ref<IPAddr>,
  ) -> Result<(int, int), error>

  /// WriteTo implements the [PacketConn] WriteTo method.
  fn WriteTo(self: Ref<IPConn>, b: Slice<uint8>, addr: Addr) -> Result<int, error>

  /// WriteToIP acts like [IPConn.WriteTo] but takes an [IPAddr].
  fn WriteToIP(self: Ref<IPConn>, b: Slice<uint8>, addr: Ref<IPAddr>) -> Result<int, error>
}

impl IPMask {
  /// Size returns the number of leading ones and total bits in the mask.
  /// If the mask is not in the canonical form--ones followed by zeros--then
  /// Size returns 0, 0.
  fn Size(self) -> (int, int)

  /// String returns the hexadecimal form of m, with no punctuation.
  fn String(self) -> string
}

impl IPNet {
  /// Contains reports whether the network includes ip.
  fn Contains(self: Ref<IPNet>, ip: IP) -> bool

  /// Network returns the address's network name, "ip+net".
  fn Network(self: Ref<IPNet>) -> string

  /// String returns the CIDR notation of n like "192.0.2.0/24"
  /// or "2001:db8::/48" as defined in RFC 4632 and RFC 4291.
  /// If the mask is not in the canonical form, it returns the
  /// string which consists of an IP address, followed by a slash
  /// character and a mask expressed as hexadecimal form with no
  /// punctuation like "198.51.100.0/c000ff00".
  fn String(self: Ref<IPNet>) -> string
}

impl Interface {
  /// Addrs returns a list of unicast interface addresses for a specific
  /// interface.
  fn Addrs(self: Ref<Interface>) -> Result<Slice<Addr>, error>

  /// MulticastAddrs returns a list of multicast, joined group addresses
  /// for a specific interface.
  fn MulticastAddrs(self: Ref<Interface>) -> Result<Slice<Addr>, error>
}

impl InvalidAddrError {
  fn Error(self) -> string

  fn Temporary(self) -> bool

  fn Timeout(self) -> bool
}

impl ListenConfig {
  /// Listen announces on the local network address.
  /// 
  /// See func Listen for a description of the network and address
  /// parameters.
  /// 
  /// The ctx argument is used while resolving the address on which to listen;
  /// it does not affect the returned Listener.
  fn Listen(
    self: Ref<ListenConfig>,
    ctx: context.Context,
    network: string,
    address: string,
  ) -> Result<Listener, error>

  /// ListenPacket announces on the local network address.
  /// 
  /// See func ListenPacket for a description of the network and address
  /// parameters.
  /// 
  /// The ctx argument is used while resolving the address on which to listen;
  /// it does not affect the returned PacketConn.
  fn ListenPacket(
    self: Ref<ListenConfig>,
    ctx: context.Context,
    network: string,
    address: string,
  ) -> Result<PacketConn, error>

  /// MultipathTCP reports whether MPTCP will be used.
  /// 
  /// This method doesn't check if MPTCP is supported by the operating
  /// system or not.
  fn MultipathTCP(self: Ref<ListenConfig>) -> bool

  /// SetMultipathTCP directs the [Listen] method to use, or not use, MPTCP,
  /// if supported by the operating system. This method overrides the
  /// system default and the GODEBUG=multipathtcp=... setting if any.
  /// 
  /// If MPTCP is not available on the host or not supported by the client,
  /// the Listen method will fall back to TCP.
  fn SetMultipathTCP(self: Ref<ListenConfig>, use: bool)
}

impl OpError {
  fn Error(self: Ref<OpError>) -> string

  fn Temporary(self: Ref<OpError>) -> bool

  fn Timeout(self: Ref<OpError>) -> bool

  fn Unwrap(self: Ref<OpError>) -> Option<error>
}

impl ParseError {
  fn Error(self: Ref<ParseError>) -> string

  fn Temporary(self: Ref<ParseError>) -> bool

  fn Timeout(self: Ref<ParseError>) -> bool
}

impl Resolver {
  /// LookupAddr performs a reverse lookup for the given address, returning a list
  /// of names mapping to that address.
  /// 
  /// The returned names are validated to be properly formatted presentation-format
  /// domain names. If the response contains invalid names, those records are filtered
  /// out and an error will be returned alongside the remaining results, if any.
  fn LookupAddr(self: Ref<Resolver>, ctx: context.Context, addr: string) -> Result<Slice<string>, error>

  /// LookupCNAME returns the canonical name for the given host.
  /// Callers that do not care about the canonical name can call
  /// [LookupHost] or [LookupIP] directly; both take care of resolving
  /// the canonical name as part of the lookup.
  /// 
  /// A canonical name is the final name after following zero
  /// or more CNAME records.
  /// LookupCNAME does not return an error if host does not
  /// contain DNS "CNAME" records, as long as host resolves to
  /// address records.
  /// 
  /// The returned canonical name is validated to be a properly
  /// formatted presentation-format domain name.
  fn LookupCNAME(self: Ref<Resolver>, ctx: context.Context, host: string) -> Result<string, error>

  /// LookupHost looks up the given host using the local resolver.
  /// It returns a slice of that host's addresses.
  fn LookupHost(self: Ref<Resolver>, ctx: context.Context, host: string) -> Result<Slice<string>, error>

  /// LookupIP looks up host for the given network using the local resolver.
  /// It returns a slice of that host's IP addresses of the type specified by
  /// network.
  /// network must be one of "ip", "ip4" or "ip6".
  fn LookupIP(
    self: Ref<Resolver>,
    ctx: context.Context,
    network: string,
    host: string,
  ) -> Result<Slice<IP>, error>

  /// LookupIPAddr looks up host using the local resolver.
  /// It returns a slice of that host's IPv4 and IPv6 addresses.
  fn LookupIPAddr(self: Ref<Resolver>, ctx: context.Context, host: string) -> Result<Slice<IPAddr>, error>

  /// LookupMX returns the DNS MX records for the given domain name sorted by preference.
  /// 
  /// The returned mail server names are validated to be properly
  /// formatted presentation-format domain names, or numeric IP addresses.
  /// If the response contains invalid names, those records are filtered out
  /// and an error will be returned alongside the remaining results, if any.
  fn LookupMX(self: Ref<Resolver>, ctx: context.Context, name: string) -> Result<Slice<Ref<MX>>, error>

  /// LookupNS returns the DNS NS records for the given domain name.
  /// 
  /// The returned name server names are validated to be properly
  /// formatted presentation-format domain names. If the response contains
  /// invalid names, those records are filtered out and an error
  /// will be returned alongside the remaining results, if any.
  fn LookupNS(self: Ref<Resolver>, ctx: context.Context, name: string) -> Result<Slice<Ref<NS>>, error>

  /// LookupNetIP looks up host using the local resolver.
  /// It returns a slice of that host's IP addresses of the type specified by
  /// network.
  /// The network must be one of "ip", "ip4" or "ip6".
  fn LookupNetIP(
    self: Ref<Resolver>,
    ctx: context.Context,
    network: string,
    host: string,
  ) -> Result<Slice<netip.Addr>, error>

  /// LookupPort looks up the port for the given network and service.
  /// 
  /// The network must be one of "tcp", "tcp4", "tcp6", "udp", "udp4", "udp6" or "ip".
  fn LookupPort(
    self: Ref<Resolver>,
    ctx: context.Context,
    network: string,
    service: string,
  ) -> Result<int, error>

  /// LookupSRV tries to resolve an [SRV] query of the given service,
  /// protocol, and domain name. The proto is "tcp" or "udp".
  /// The returned records are sorted by priority and randomized
  /// by weight within a priority.
  /// 
  /// LookupSRV constructs the DNS name to look up following RFC 2782.
  /// That is, it looks up _service._proto.name. To accommodate services
  /// publishing SRV records under non-standard names, if both service
  /// and proto are empty strings, LookupSRV looks up name directly.
  /// 
  /// The returned service names are validated to be properly
  /// formatted presentation-format domain names. If the response contains
  /// invalid names, those records are filtered out and an error
  /// will be returned alongside the remaining results, if any.
  fn LookupSRV(
    self: Ref<Resolver>,
    ctx: context.Context,
    service: string,
    proto: string,
    name: string,
  ) -> Result<(string, Slice<Ref<SRV>>), error>

  /// LookupTXT returns the DNS TXT records for the given domain name.
  /// 
  /// If a DNS TXT record holds multiple strings, they are concatenated as a
  /// single string.
  fn LookupTXT(self: Ref<Resolver>, ctx: context.Context, name: string) -> Result<Slice<string>, error>
}

impl TCPAddr {
  /// AddrPort returns the [TCPAddr] a as a [netip.AddrPort].
  /// 
  /// If a.Port does not fit in a uint16, it's silently truncated.
  /// 
  /// If a is nil, a zero value is returned.
  fn AddrPort(self: Ref<TCPAddr>) -> netip.AddrPort

  /// Network returns the address's network name, "tcp".
  fn Network(self: Ref<TCPAddr>) -> string

  fn String(self: Ref<TCPAddr>) -> string
}

impl TCPConn {
  /// Close closes the connection.
  #[allow(unused_result)]
  fn Close(self: Ref<TCPConn>) -> Result<(), error>

  /// CloseRead shuts down the reading side of the TCP connection.
  /// Most callers should just use Close.
  fn CloseRead(self: Ref<TCPConn>) -> Result<(), error>

  /// CloseWrite shuts down the writing side of the TCP connection.
  /// Most callers should just use Close.
  fn CloseWrite(self: Ref<TCPConn>) -> Result<(), error>

  /// File returns a copy of the underlying [os.File].
  /// It is the caller's responsibility to close f when finished.
  /// Closing c does not affect f, and closing f does not affect c.
  /// 
  /// The returned os.File's file descriptor is different from the connection's.
  /// Attempting to change properties of the original using this duplicate
  /// may or may not have the desired effect.
  /// 
  /// On Windows, the returned os.File's file descriptor is not usable
  /// on other processes.
  fn File(self: Ref<TCPConn>) -> Result<Ref<os.File>, error>

  /// LocalAddr returns the local network address.
  /// The Addr returned is shared by all invocations of LocalAddr, so
  /// do not modify it.
  fn LocalAddr(self: Ref<TCPConn>) -> Addr

  /// MultipathTCP reports whether the ongoing connection is using MPTCP.
  /// 
  /// If Multipath TCP is not supported by the host, by the other peer or
  /// intentionally / accidentally filtered out by a device in between, a
  /// fallback to TCP will be done. This method does its best to check if
  /// MPTCP is still being used or not.
  /// 
  /// On Linux, more conditions are verified on kernels >= v5.16, improving
  /// the results.
  fn MultipathTCP(self: Ref<TCPConn>) -> Result<bool, error>

  /// Read implements the Conn Read method.
  fn Read(self: Ref<TCPConn>, mut b: Slice<uint8>) -> Partial<int, error>

  /// ReadFrom implements the [io.ReaderFrom] ReadFrom method.
  fn ReadFrom(self: Ref<TCPConn>, r: io.Reader) -> Result<int64, error>

  /// RemoteAddr returns the remote network address.
  /// The Addr returned is shared by all invocations of RemoteAddr, so
  /// do not modify it.
  fn RemoteAddr(self: Ref<TCPConn>) -> Addr

  /// SetDeadline implements the Conn SetDeadline method.
  fn SetDeadline(self: Ref<TCPConn>, t: time.Time) -> Result<(), error>

  /// SetKeepAlive sets whether the operating system should send
  /// keep-alive messages on the connection.
  fn SetKeepAlive(self: Ref<TCPConn>, keepalive: bool) -> Result<(), error>

  /// SetKeepAliveConfig configures keep-alive messages sent by the operating system.
  fn SetKeepAliveConfig(self: Ref<TCPConn>, config: KeepAliveConfig) -> Result<(), error>

  /// SetKeepAlivePeriod sets the duration the connection needs to
  /// remain idle before TCP starts sending keepalive probes.
  /// 
  /// Note that calling this method on Windows prior to Windows 10 version 1709
  /// will reset the KeepAliveInterval to the default system value, which is normally 1 second.
  fn SetKeepAlivePeriod(self: Ref<TCPConn>, d: time.Duration) -> Result<(), error>

  /// SetLinger sets the behavior of Close on a connection which still
  /// has data waiting to be sent or to be acknowledged.
  /// 
  /// If sec < 0 (the default), the operating system finishes sending the
  /// data in the background.
  /// 
  /// If sec == 0, the operating system discards any unsent or
  /// unacknowledged data.
  /// 
  /// If sec > 0, the data is sent in the background as with sec < 0.
  /// On some operating systems including Linux, this may cause Close to block
  /// until all data has been sent or discarded.
  /// On some operating systems after sec seconds have elapsed any remaining
  /// unsent data may be discarded.
  fn SetLinger(self: Ref<TCPConn>, sec: int) -> Result<(), error>

  /// SetNoDelay controls whether the operating system should delay
  /// packet transmission in hopes of sending fewer packets (Nagle's
  /// algorithm).  The default is true (no delay), meaning that data is
  /// sent as soon as possible after a Write.
  fn SetNoDelay(self: Ref<TCPConn>, noDelay: bool) -> Result<(), error>

  /// SetReadBuffer sets the size of the operating system's
  /// receive buffer associated with the connection.
  fn SetReadBuffer(self: Ref<TCPConn>, bytes: int) -> Result<(), error>

  /// SetReadDeadline implements the Conn SetReadDeadline method.
  fn SetReadDeadline(self: Ref<TCPConn>, t: time.Time) -> Result<(), error>

  /// SetWriteBuffer sets the size of the operating system's
  /// transmit buffer associated with the connection.
  fn SetWriteBuffer(self: Ref<TCPConn>, bytes: int) -> Result<(), error>

  /// SetWriteDeadline implements the Conn SetWriteDeadline method.
  fn SetWriteDeadline(self: Ref<TCPConn>, t: time.Time) -> Result<(), error>

  /// SyscallConn returns a raw network connection.
  /// This implements the [syscall.Conn] interface.
  fn SyscallConn(self: Ref<TCPConn>) -> Result<syscall.RawConn, error>

  /// Write implements the Conn Write method.
  fn Write(self: Ref<TCPConn>, b: Slice<uint8>) -> Partial<int, error>

  /// WriteTo implements the io.WriterTo WriteTo method.
  fn WriteTo(self: Ref<TCPConn>, w: io.Writer) -> Result<int64, error>
}

impl TCPListener {
  /// Accept implements the Accept method in the [Listener] interface; it
  /// waits for the next call and returns a generic [Conn].
  fn Accept(self: Ref<TCPListener>) -> Result<Conn, error>

  /// AcceptTCP accepts the next incoming call and returns the new
  /// connection.
  fn AcceptTCP(self: Ref<TCPListener>) -> Result<Ref<TCPConn>, error>

  /// Addr returns the listener's network address, a [*TCPAddr].
  /// The Addr returned is shared by all invocations of Addr, so
  /// do not modify it.
  fn Addr(self: Ref<TCPListener>) -> Addr

  /// Close stops listening on the TCP address.
  /// Already Accepted connections are not closed.
  #[allow(unused_result)]
  fn Close(self: Ref<TCPListener>) -> Result<(), error>

  /// File returns a copy of the underlying [os.File].
  /// It is the caller's responsibility to close f when finished.
  /// Closing l does not affect f, and closing f does not affect l.
  /// 
  /// The returned os.File's file descriptor is different from the
  /// connection's. Attempting to change properties of the original
  /// using this duplicate may or may not have the desired effect.
  /// 
  /// On Windows, the returned os.File's file descriptor is not
  /// usable on other processes.
  fn File(self: Ref<TCPListener>) -> Result<Ref<os.File>, error>

  /// SetDeadline sets the deadline associated with the listener.
  /// A zero time value disables the deadline.
  fn SetDeadline(self: Ref<TCPListener>, t: time.Time) -> Result<(), error>

  /// SyscallConn returns a raw network connection.
  /// This implements the [syscall.Conn] interface.
  /// 
  /// The returned RawConn only supports calling Control. Read and
  /// Write return an error.
  fn SyscallConn(self: Ref<TCPListener>) -> Result<syscall.RawConn, error>
}

impl UDPAddr {
  /// AddrPort returns the [UDPAddr] a as a [netip.AddrPort].
  /// 
  /// If a.Port does not fit in a uint16, it's silently truncated.
  /// 
  /// If a is nil, a zero value is returned.
  fn AddrPort(self: Ref<UDPAddr>) -> netip.AddrPort

  /// Network returns the address's network name, "udp".
  fn Network(self: Ref<UDPAddr>) -> string

  fn String(self: Ref<UDPAddr>) -> string
}

impl UDPConn {
  /// Close closes the connection.
  #[allow(unused_result)]
  fn Close(self: Ref<UDPConn>) -> Result<(), error>

  /// File returns a copy of the underlying [os.File].
  /// It is the caller's responsibility to close f when finished.
  /// Closing c does not affect f, and closing f does not affect c.
  /// 
  /// The returned os.File's file descriptor is different from the connection's.
  /// Attempting to change properties of the original using this duplicate
  /// may or may not have the desired effect.
  /// 
  /// On Windows, the returned os.File's file descriptor is not usable
  /// on other processes.
  fn File(self: Ref<UDPConn>) -> Result<Ref<os.File>, error>

  /// LocalAddr returns the local network address.
  /// The Addr returned is shared by all invocations of LocalAddr, so
  /// do not modify it.
  fn LocalAddr(self: Ref<UDPConn>) -> Addr

  /// Read implements the Conn Read method.
  fn Read(self: Ref<UDPConn>, mut b: Slice<uint8>) -> Partial<int, error>

  /// ReadFrom implements the [PacketConn] ReadFrom method.
  fn ReadFrom(self: Ref<UDPConn>, mut b: Slice<uint8>) -> Result<(int, Addr), error>

  /// ReadFromUDP acts like [UDPConn.ReadFrom] but returns a UDPAddr.
  fn ReadFromUDP(self: Ref<UDPConn>, mut b: Slice<uint8>) -> Result<(int, Ref<UDPAddr>), error>

  /// ReadFromUDPAddrPort acts like ReadFrom but returns a [netip.AddrPort].
  /// 
  /// If c is bound to an unspecified address, the returned
  /// netip.AddrPort's address might be an IPv4-mapped IPv6 address.
  /// Use [netip.Addr.Unmap] to get the address without the IPv6 prefix.
  fn ReadFromUDPAddrPort(self: Ref<UDPConn>, mut b: Slice<uint8>) -> Result<(int, netip.AddrPort), error>

  /// ReadMsgUDP reads a message from c, copying the payload into b and
  /// the associated out-of-band data into oob. It returns the number of
  /// bytes copied into b, the number of bytes copied into oob, the flags
  /// that were set on the message and the source address of the message.
  /// 
  /// The packages [golang.org/x/net/ipv4] and [golang.org/x/net/ipv6] can be
  /// used to manipulate IP-level socket options in oob.
  fn ReadMsgUDP(self: Ref<UDPConn>, mut b: Slice<uint8>, mut oob: Slice<uint8>) -> Result<(int, int, int, Ref<UDPAddr>), error>

  /// ReadMsgUDPAddrPort is like [UDPConn.ReadMsgUDP] but returns an [netip.AddrPort] instead of a [UDPAddr].
  fn ReadMsgUDPAddrPort(
    self: Ref<UDPConn>,
    mut b: Slice<uint8>,
    mut oob: Slice<uint8>,
  ) -> Result<(int, int, int, netip.AddrPort), error>

  /// RemoteAddr returns the remote network address.
  /// The Addr returned is shared by all invocations of RemoteAddr, so
  /// do not modify it.
  fn RemoteAddr(self: Ref<UDPConn>) -> Addr

  /// SetDeadline implements the Conn SetDeadline method.
  fn SetDeadline(self: Ref<UDPConn>, t: time.Time) -> Result<(), error>

  /// SetReadBuffer sets the size of the operating system's
  /// receive buffer associated with the connection.
  fn SetReadBuffer(self: Ref<UDPConn>, bytes: int) -> Result<(), error>

  /// SetReadDeadline implements the Conn SetReadDeadline method.
  fn SetReadDeadline(self: Ref<UDPConn>, t: time.Time) -> Result<(), error>

  /// SetWriteBuffer sets the size of the operating system's
  /// transmit buffer associated with the connection.
  fn SetWriteBuffer(self: Ref<UDPConn>, bytes: int) -> Result<(), error>

  /// SetWriteDeadline implements the Conn SetWriteDeadline method.
  fn SetWriteDeadline(self: Ref<UDPConn>, t: time.Time) -> Result<(), error>

  /// SyscallConn returns a raw network connection.
  /// This implements the [syscall.Conn] interface.
  fn SyscallConn(self: Ref<UDPConn>) -> Result<syscall.RawConn, error>

  /// Write implements the Conn Write method.
  fn Write(self: Ref<UDPConn>, b: Slice<uint8>) -> Partial<int, error>

  /// WriteMsgUDP writes a message to addr via c if c isn't connected, or
  /// to c's remote address if c is connected (in which case addr must be
  /// nil). The payload is copied from b and the associated out-of-band
  /// data is copied from oob. It returns the number of payload and
  /// out-of-band bytes written.
  /// 
  /// The packages [golang.org/x/net/ipv4] and [golang.org/x/net/ipv6] can be
  /// used to manipulate IP-level socket options in oob.
  fn WriteMsgUDP(
    self: Ref<UDPConn>,
    b: Slice<uint8>,
    oob: Slice<uint8>,
    addr: Ref<UDPAddr>,
  ) -> Result<(int, int), error>

  /// WriteMsgUDPAddrPort is like [UDPConn.WriteMsgUDP] but takes a [netip.AddrPort] instead of a [UDPAddr].
  fn WriteMsgUDPAddrPort(
    self: Ref<UDPConn>,
    b: Slice<uint8>,
    oob: Slice<uint8>,
    addr: netip.AddrPort,
  ) -> Result<(int, int), error>

  /// WriteTo implements the [PacketConn] WriteTo method.
  fn WriteTo(self: Ref<UDPConn>, b: Slice<uint8>, addr: Addr) -> Result<int, error>

  /// WriteToUDP acts like [UDPConn.WriteTo] but takes a [UDPAddr].
  fn WriteToUDP(self: Ref<UDPConn>, b: Slice<uint8>, addr: Ref<UDPAddr>) -> Result<int, error>

  /// WriteToUDPAddrPort acts like [UDPConn.WriteTo] but takes a [netip.AddrPort].
  fn WriteToUDPAddrPort(
    self: Ref<UDPConn>,
    b: Slice<uint8>,
    addr: netip.AddrPort,
  ) -> Result<int, error>
}

impl UnixAddr {
  /// Network returns the address's network name, "unix", "unixgram" or
  /// "unixpacket".
  fn Network(self: Ref<UnixAddr>) -> string

  fn String(self: Ref<UnixAddr>) -> string
}

impl UnixConn {
  /// Close closes the connection.
  #[allow(unused_result)]
  fn Close(self: Ref<UnixConn>) -> Result<(), error>

  /// CloseRead shuts down the reading side of the Unix domain connection.
  /// Most callers should just use [UnixConn.Close].
  fn CloseRead(self: Ref<UnixConn>) -> Result<(), error>

  /// CloseWrite shuts down the writing side of the Unix domain connection.
  /// Most callers should just use [UnixConn.Close].
  fn CloseWrite(self: Ref<UnixConn>) -> Result<(), error>

  /// File returns a copy of the underlying [os.File].
  /// It is the caller's responsibility to close f when finished.
  /// Closing c does not affect f, and closing f does not affect c.
  /// 
  /// The returned os.File's file descriptor is different from the connection's.
  /// Attempting to change properties of the original using this duplicate
  /// may or may not have the desired effect.
  /// 
  /// On Windows, the returned os.File's file descriptor is not usable
  /// on other processes.
  fn File(self: Ref<UnixConn>) -> Result<Ref<os.File>, error>

  /// LocalAddr returns the local network address.
  /// The Addr returned is shared by all invocations of LocalAddr, so
  /// do not modify it.
  fn LocalAddr(self: Ref<UnixConn>) -> Addr

  /// Read implements the Conn Read method.
  fn Read(self: Ref<UnixConn>, mut b: Slice<uint8>) -> Partial<int, error>

  /// ReadFrom implements the [PacketConn].ReadFrom method.
  fn ReadFrom(self: Ref<UnixConn>, mut b: Slice<uint8>) -> Result<(int, Addr), error>

  /// ReadFromUnix acts like [UnixConn.ReadFrom] but returns a [UnixAddr].
  fn ReadFromUnix(self: Ref<UnixConn>, mut b: Slice<uint8>) -> Result<(int, Ref<UnixAddr>), error>

  /// ReadMsgUnix reads a message from c, copying the payload into b and
  /// the associated out-of-band data into oob. It returns the number of
  /// bytes copied into b, the number of bytes copied into oob, the flags
  /// that were set on the message and the source address of the message.
  /// 
  /// Note that if len(b) == 0 and len(oob) > 0, this function will still
  /// read (and discard) 1 byte from the connection.
  fn ReadMsgUnix(
    self: Ref<UnixConn>,
    mut b: Slice<uint8>,
    mut oob: Slice<uint8>,
  ) -> Result<(int, int, int, Ref<UnixAddr>), error>

  /// RemoteAddr returns the remote network address.
  /// The Addr returned is shared by all invocations of RemoteAddr, so
  /// do not modify it.
  fn RemoteAddr(self: Ref<UnixConn>) -> Addr

  /// SetDeadline implements the Conn SetDeadline method.
  fn SetDeadline(self: Ref<UnixConn>, t: time.Time) -> Result<(), error>

  /// SetReadBuffer sets the size of the operating system's
  /// receive buffer associated with the connection.
  fn SetReadBuffer(self: Ref<UnixConn>, bytes: int) -> Result<(), error>

  /// SetReadDeadline implements the Conn SetReadDeadline method.
  fn SetReadDeadline(self: Ref<UnixConn>, t: time.Time) -> Result<(), error>

  /// SetWriteBuffer sets the size of the operating system's
  /// transmit buffer associated with the connection.
  fn SetWriteBuffer(self: Ref<UnixConn>, bytes: int) -> Result<(), error>

  /// SetWriteDeadline implements the Conn SetWriteDeadline method.
  fn SetWriteDeadline(self: Ref<UnixConn>, t: time.Time) -> Result<(), error>

  /// SyscallConn returns a raw network connection.
  /// This implements the [syscall.Conn] interface.
  fn SyscallConn(self: Ref<UnixConn>) -> Result<syscall.RawConn, error>

  /// Write implements the Conn Write method.
  fn Write(self: Ref<UnixConn>, b: Slice<uint8>) -> Partial<int, error>

  /// WriteMsgUnix writes a message to addr via c, copying the payload
  /// from b and the associated out-of-band data from oob. It returns the
  /// number of payload and out-of-band bytes written.
  /// 
  /// Note that if len(b) == 0 and len(oob) > 0, this function will still
  /// write 1 byte to the connection.
  fn WriteMsgUnix(
    self: Ref<UnixConn>,
    b: Slice<uint8>,
    oob: Slice<uint8>,
    addr: Ref<UnixAddr>,
  ) -> Result<(int, int), error>

  /// WriteTo implements the [PacketConn].WriteTo method.
  fn WriteTo(self: Ref<UnixConn>, b: Slice<uint8>, addr: Addr) -> Result<int, error>

  /// WriteToUnix acts like [UnixConn.WriteTo] but takes a [UnixAddr].
  fn WriteToUnix(self: Ref<UnixConn>, b: Slice<uint8>, addr: Ref<UnixAddr>) -> Result<int, error>
}

impl UnixListener {
  /// Accept implements the Accept method in the [Listener] interface.
  /// Returned connections will be of type [*UnixConn].
  fn Accept(self: Ref<UnixListener>) -> Result<Conn, error>

  /// AcceptUnix accepts the next incoming call and returns the new
  /// connection.
  fn AcceptUnix(self: Ref<UnixListener>) -> Result<Ref<UnixConn>, error>

  /// Addr returns the listener's network address.
  /// The [Addr] returned is shared by all invocations of Addr, so
  /// do not modify it.
  fn Addr(self: Ref<UnixListener>) -> Addr

  /// Close stops listening on the Unix address. Already accepted
  /// connections are not closed.
  #[allow(unused_result)]
  fn Close(self: Ref<UnixListener>) -> Result<(), error>

  /// File returns a copy of the underlying [os.File].
  /// It is the caller's responsibility to close f when finished.
  /// Closing l does not affect f, and closing f does not affect l.
  /// 
  /// The returned [os.File]'s file descriptor is different from the
  /// connection's. Attempting to change properties of the original
  /// using this duplicate may or may not have the desired effect.
  /// 
  /// On Windows, the returned os.File's file descriptor is not
  /// usable on other processes.
  fn File(self: Ref<UnixListener>) -> Result<Ref<os.File>, error>

  /// SetDeadline sets the deadline associated with the listener.
  /// A zero time value disables the deadline.
  fn SetDeadline(self: Ref<UnixListener>, t: time.Time) -> Result<(), error>

  /// SetUnlinkOnClose sets whether the underlying socket file should be removed
  /// from the file system when the listener is closed.
  /// 
  /// The default behavior is to unlink the socket file only when package net created it.
  /// That is, when the listener and the underlying socket file were created by a call to
  /// Listen or ListenUnix, then by default closing the listener will remove the socket file.
  /// but if the listener was created by a call to FileListener to use an already existing
  /// socket file, then by default closing the listener will not remove the socket file.
  fn SetUnlinkOnClose(self: Ref<UnixListener>, unlink: bool)

  /// SyscallConn returns a raw network connection.
  /// This implements the [syscall.Conn] interface.
  /// 
  /// The returned [syscall.RawConn] only supports calling Control. Read and
  /// Write return an error.
  fn SyscallConn(self: Ref<UnixListener>) -> Result<syscall.RawConn, error>
}

impl UnknownNetworkError {
  fn Error(self) -> string

  fn Temporary(self) -> bool

  fn Timeout(self) -> bool
}