rsloop 0.1.3__tar.gz → 0.1.4__tar.gz

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.
Files changed (42) hide show
  1. {rsloop-0.1.3 → rsloop-0.1.4}/.gitignore +2 -0
  2. {rsloop-0.1.3 → rsloop-0.1.4}/Cargo.lock +235 -10
  3. {rsloop-0.1.3 → rsloop-0.1.4}/Cargo.toml +4 -1
  4. {rsloop-0.1.3 → rsloop-0.1.4}/PKG-INFO +7 -8
  5. {rsloop-0.1.3 → rsloop-0.1.4}/README.md +6 -7
  6. rsloop-0.1.4/justfile +4 -0
  7. {rsloop-0.1.3 → rsloop-0.1.4}/pyproject.toml +1 -1
  8. {rsloop-0.1.3 → rsloop-0.1.4}/python/rsloop/__init__.py +37 -0
  9. rsloop-0.1.4/scripts/generate-test-tls-certs.sh +46 -0
  10. {rsloop-0.1.3 → rsloop-0.1.4}/src/fd_ops.rs +27 -5
  11. {rsloop-0.1.3 → rsloop-0.1.4}/src/lib.rs +1 -0
  12. {rsloop-0.1.3 → rsloop-0.1.4}/src/python_api.rs +154 -56
  13. {rsloop-0.1.3 → rsloop-0.1.4}/src/stream_transport.rs +899 -38
  14. rsloop-0.1.4/src/tls.rs +311 -0
  15. rsloop-0.1.4/tests/test_tls.py +298 -0
  16. {rsloop-0.1.3 → rsloop-0.1.4}/uv.lock +1 -1
  17. {rsloop-0.1.3 → rsloop-0.1.4}/.github/workflows/wheels.yml +0 -0
  18. {rsloop-0.1.3 → rsloop-0.1.4}/LICENSE +0 -0
  19. {rsloop-0.1.3 → rsloop-0.1.4}/benchmarks/README.md +0 -0
  20. {rsloop-0.1.3 → rsloop-0.1.4}/benchmarks/compare_event_loops.py +0 -0
  21. {rsloop-0.1.3 → rsloop-0.1.4}/build.rs +0 -0
  22. {rsloop-0.1.3 → rsloop-0.1.4}/demo/README.md +0 -0
  23. {rsloop-0.1.3 → rsloop-0.1.4}/demo/fastapi_service.py +0 -0
  24. {rsloop-0.1.3 → rsloop-0.1.4}/examples/01_basics.py +0 -0
  25. {rsloop-0.1.3 → rsloop-0.1.4}/examples/02_fd_and_sockets.py +0 -0
  26. {rsloop-0.1.3 → rsloop-0.1.4}/examples/03_streams.py +0 -0
  27. {rsloop-0.1.3 → rsloop-0.1.4}/examples/04_unix_and_accepted_socket.py +0 -0
  28. {rsloop-0.1.3 → rsloop-0.1.4}/examples/05_pipes_signals_subprocesses.py +0 -0
  29. {rsloop-0.1.3 → rsloop-0.1.4}/rsloop.png +0 -0
  30. {rsloop-0.1.3 → rsloop-0.1.4}/scripts/build-wheels.sh +0 -0
  31. {rsloop-0.1.3 → rsloop-0.1.4}/src/async_event.rs +0 -0
  32. {rsloop-0.1.3 → rsloop-0.1.4}/src/blocking.rs +0 -0
  33. {rsloop-0.1.3 → rsloop-0.1.4}/src/callbacks.rs +0 -0
  34. {rsloop-0.1.3 → rsloop-0.1.4}/src/context.rs +0 -0
  35. {rsloop-0.1.3 → rsloop-0.1.4}/src/errors.rs +0 -0
  36. {rsloop-0.1.3 → rsloop-0.1.4}/src/fast_streams.rs +0 -0
  37. {rsloop-0.1.3 → rsloop-0.1.4}/src/loop_core.rs +0 -0
  38. {rsloop-0.1.3 → rsloop-0.1.4}/src/process_transport.rs +0 -0
  39. {rsloop-0.1.3 → rsloop-0.1.4}/src/profiler.rs +0 -0
  40. {rsloop-0.1.3 → rsloop-0.1.4}/src/python_names.rs +0 -0
  41. {rsloop-0.1.3 → rsloop-0.1.4}/src/runtime.rs +0 -0
  42. {rsloop-0.1.3 → rsloop-0.1.4}/tests/test_run.py +0 -0
@@ -11,3 +11,5 @@ python/rsloop/_loop*
11
11
 
12
12
  benchmarks/profiles*
13
13
  benchmarks/compare_event_loops.results.json
14
+
15
+ tests/fixtures/tls
@@ -118,7 +118,7 @@ dependencies = [
118
118
  "polling",
119
119
  "rustix",
120
120
  "slab",
121
- "windows-sys",
121
+ "windows-sys 0.61.2",
122
122
  ]
123
123
 
124
124
  [[package]]
@@ -165,7 +165,7 @@ dependencies = [
165
165
  "rustix",
166
166
  "signal-hook-registry",
167
167
  "slab",
168
- "windows-sys",
168
+ "windows-sys 0.61.2",
169
169
  ]
170
170
 
171
171
  [[package]]
@@ -213,6 +213,28 @@ version = "1.5.0"
213
213
  source = "registry+https://github.com/rust-lang/crates.io-index"
214
214
  checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
215
215
 
216
+ [[package]]
217
+ name = "aws-lc-rs"
218
+ version = "1.16.2"
219
+ source = "registry+https://github.com/rust-lang/crates.io-index"
220
+ checksum = "a054912289d18629dc78375ba2c3726a3afe3ff71b4edba9dedfca0e3446d1fc"
221
+ dependencies = [
222
+ "aws-lc-sys",
223
+ "zeroize",
224
+ ]
225
+
226
+ [[package]]
227
+ name = "aws-lc-sys"
228
+ version = "0.39.0"
229
+ source = "registry+https://github.com/rust-lang/crates.io-index"
230
+ checksum = "1fa7e52a4c5c547c741610a2c6f123f3881e409b714cd27e6798ef020c514f0a"
231
+ dependencies = [
232
+ "cc",
233
+ "cmake",
234
+ "dunce",
235
+ "fs_extra",
236
+ ]
237
+
216
238
  [[package]]
217
239
  name = "backtrace"
218
240
  version = "0.3.76"
@@ -272,6 +294,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
272
294
  checksum = "7a0dd1ca384932ff3641c8718a02769f1698e7563dc6974ffd03346116310423"
273
295
  dependencies = [
274
296
  "find-msvc-tools",
297
+ "jobserver",
298
+ "libc",
275
299
  "shlex",
276
300
  ]
277
301
 
@@ -281,6 +305,15 @@ version = "1.0.4"
281
305
  source = "registry+https://github.com/rust-lang/crates.io-index"
282
306
  checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
283
307
 
308
+ [[package]]
309
+ name = "cmake"
310
+ version = "0.1.57"
311
+ source = "registry+https://github.com/rust-lang/crates.io-index"
312
+ checksum = "75443c44cd6b379beb8c5b45d85d0773baf31cce901fe7bb252f4eff3008ef7d"
313
+ dependencies = [
314
+ "cc",
315
+ ]
316
+
284
317
  [[package]]
285
318
  name = "concurrent-queue"
286
319
  version = "2.5.0"
@@ -314,6 +347,12 @@ dependencies = [
314
347
  "uuid",
315
348
  ]
316
349
 
350
+ [[package]]
351
+ name = "dunce"
352
+ version = "1.0.5"
353
+ source = "registry+https://github.com/rust-lang/crates.io-index"
354
+ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813"
355
+
317
356
  [[package]]
318
357
  name = "equator"
319
358
  version = "0.4.2"
@@ -347,7 +386,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
347
386
  checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
348
387
  dependencies = [
349
388
  "libc",
350
- "windows-sys",
389
+ "windows-sys 0.61.2",
351
390
  ]
352
391
 
353
392
  [[package]]
@@ -407,6 +446,12 @@ version = "0.1.5"
407
446
  source = "registry+https://github.com/rust-lang/crates.io-index"
408
447
  checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
409
448
 
449
+ [[package]]
450
+ name = "fs_extra"
451
+ version = "1.3.0"
452
+ source = "registry+https://github.com/rust-lang/crates.io-index"
453
+ checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"
454
+
410
455
  [[package]]
411
456
  name = "futures"
412
457
  version = "0.3.32"
@@ -496,6 +541,17 @@ dependencies = [
496
541
  "slab",
497
542
  ]
498
543
 
544
+ [[package]]
545
+ name = "getrandom"
546
+ version = "0.2.17"
547
+ source = "registry+https://github.com/rust-lang/crates.io-index"
548
+ checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
549
+ dependencies = [
550
+ "cfg-if",
551
+ "libc",
552
+ "wasi",
553
+ ]
554
+
499
555
  [[package]]
500
556
  name = "getrandom"
501
557
  version = "0.3.4"
@@ -610,7 +666,7 @@ checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46"
610
666
  dependencies = [
611
667
  "hermit-abi",
612
668
  "libc",
613
- "windows-sys",
669
+ "windows-sys 0.61.2",
614
670
  ]
615
671
 
616
672
  [[package]]
@@ -619,6 +675,16 @@ version = "1.0.18"
619
675
  source = "registry+https://github.com/rust-lang/crates.io-index"
620
676
  checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
621
677
 
678
+ [[package]]
679
+ name = "jobserver"
680
+ version = "0.1.34"
681
+ source = "registry+https://github.com/rust-lang/crates.io-index"
682
+ checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33"
683
+ dependencies = [
684
+ "getrandom 0.3.4",
685
+ "libc",
686
+ ]
687
+
622
688
  [[package]]
623
689
  name = "js-sys"
624
690
  version = "0.3.91"
@@ -780,7 +846,7 @@ dependencies = [
780
846
  "hermit-abi",
781
847
  "pin-project-lite",
782
848
  "rustix",
783
- "windows-sys",
849
+ "windows-sys 0.61.2",
784
850
  ]
785
851
 
786
852
  [[package]]
@@ -941,10 +1007,25 @@ dependencies = [
941
1007
  "bytemuck",
942
1008
  ]
943
1009
 
1010
+ [[package]]
1011
+ name = "ring"
1012
+ version = "0.17.14"
1013
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1014
+ checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7"
1015
+ dependencies = [
1016
+ "cc",
1017
+ "cfg-if",
1018
+ "getrandom 0.2.17",
1019
+ "libc",
1020
+ "untrusted",
1021
+ "windows-sys 0.52.0",
1022
+ ]
1023
+
944
1024
  [[package]]
945
1025
  name = "rsloop"
946
- version = "0.1.3"
1026
+ version = "0.1.4"
947
1027
  dependencies = [
1028
+ "async-std",
948
1029
  "crossbeam-channel",
949
1030
  "futures",
950
1031
  "libc",
@@ -952,9 +1033,11 @@ dependencies = [
952
1033
  "pyo3",
953
1034
  "pyo3-async-runtimes",
954
1035
  "pyo3-build-config",
1036
+ "rustls",
1037
+ "rustls-pemfile",
955
1038
  "signal-hook",
956
1039
  "socket2",
957
- "windows-sys",
1040
+ "windows-sys 0.61.2",
958
1041
  ]
959
1042
 
960
1043
  [[package]]
@@ -973,7 +1056,52 @@ dependencies = [
973
1056
  "errno",
974
1057
  "libc",
975
1058
  "linux-raw-sys",
976
- "windows-sys",
1059
+ "windows-sys 0.61.2",
1060
+ ]
1061
+
1062
+ [[package]]
1063
+ name = "rustls"
1064
+ version = "0.23.37"
1065
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1066
+ checksum = "758025cb5fccfd3bc2fd74708fd4682be41d99e5dff73c377c0646c6012c73a4"
1067
+ dependencies = [
1068
+ "aws-lc-rs",
1069
+ "log",
1070
+ "once_cell",
1071
+ "rustls-pki-types",
1072
+ "rustls-webpki",
1073
+ "subtle",
1074
+ "zeroize",
1075
+ ]
1076
+
1077
+ [[package]]
1078
+ name = "rustls-pemfile"
1079
+ version = "2.2.0"
1080
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1081
+ checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50"
1082
+ dependencies = [
1083
+ "rustls-pki-types",
1084
+ ]
1085
+
1086
+ [[package]]
1087
+ name = "rustls-pki-types"
1088
+ version = "1.14.0"
1089
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1090
+ checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd"
1091
+ dependencies = [
1092
+ "zeroize",
1093
+ ]
1094
+
1095
+ [[package]]
1096
+ name = "rustls-webpki"
1097
+ version = "0.103.10"
1098
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1099
+ checksum = "df33b2b81ac578cabaf06b89b0631153a3f416b0a886e8a7a1707fb51abbd1ef"
1100
+ dependencies = [
1101
+ "aws-lc-rs",
1102
+ "ring",
1103
+ "rustls-pki-types",
1104
+ "untrusted",
977
1105
  ]
978
1106
 
979
1107
  [[package]]
@@ -1081,7 +1209,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1081
1209
  checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e"
1082
1210
  dependencies = [
1083
1211
  "libc",
1084
- "windows-sys",
1212
+ "windows-sys 0.61.2",
1085
1213
  ]
1086
1214
 
1087
1215
  [[package]]
@@ -1105,6 +1233,12 @@ version = "0.1.0"
1105
1233
  source = "registry+https://github.com/rust-lang/crates.io-index"
1106
1234
  checksum = "9091b6114800a5f2141aee1d1b9d6ca3592ac062dc5decb3764ec5895a47b4eb"
1107
1235
 
1236
+ [[package]]
1237
+ name = "subtle"
1238
+ version = "2.6.1"
1239
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1240
+ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
1241
+
1108
1242
  [[package]]
1109
1243
  name = "symbolic-common"
1110
1244
  version = "12.17.2"
@@ -1154,7 +1288,7 @@ dependencies = [
1154
1288
  "getrandom 0.4.2",
1155
1289
  "once_cell",
1156
1290
  "rustix",
1157
- "windows-sys",
1291
+ "windows-sys 0.61.2",
1158
1292
  ]
1159
1293
 
1160
1294
  [[package]]
@@ -1189,6 +1323,12 @@ version = "0.2.6"
1189
1323
  source = "registry+https://github.com/rust-lang/crates.io-index"
1190
1324
  checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
1191
1325
 
1326
+ [[package]]
1327
+ name = "untrusted"
1328
+ version = "0.9.0"
1329
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1330
+ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
1331
+
1192
1332
  [[package]]
1193
1333
  name = "uuid"
1194
1334
  version = "1.22.0"
@@ -1211,6 +1351,12 @@ version = "0.9.5"
1211
1351
  source = "registry+https://github.com/rust-lang/crates.io-index"
1212
1352
  checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
1213
1353
 
1354
+ [[package]]
1355
+ name = "wasi"
1356
+ version = "0.11.1+wasi-snapshot-preview1"
1357
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1358
+ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
1359
+
1214
1360
  [[package]]
1215
1361
  name = "wasip2"
1216
1362
  version = "1.0.2+wasi-0.2.9"
@@ -1360,6 +1506,15 @@ version = "0.2.1"
1360
1506
  source = "registry+https://github.com/rust-lang/crates.io-index"
1361
1507
  checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
1362
1508
 
1509
+ [[package]]
1510
+ name = "windows-sys"
1511
+ version = "0.52.0"
1512
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1513
+ checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
1514
+ dependencies = [
1515
+ "windows-targets",
1516
+ ]
1517
+
1363
1518
  [[package]]
1364
1519
  name = "windows-sys"
1365
1520
  version = "0.61.2"
@@ -1369,6 +1524,70 @@ dependencies = [
1369
1524
  "windows-link",
1370
1525
  ]
1371
1526
 
1527
+ [[package]]
1528
+ name = "windows-targets"
1529
+ version = "0.52.6"
1530
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1531
+ checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
1532
+ dependencies = [
1533
+ "windows_aarch64_gnullvm",
1534
+ "windows_aarch64_msvc",
1535
+ "windows_i686_gnu",
1536
+ "windows_i686_gnullvm",
1537
+ "windows_i686_msvc",
1538
+ "windows_x86_64_gnu",
1539
+ "windows_x86_64_gnullvm",
1540
+ "windows_x86_64_msvc",
1541
+ ]
1542
+
1543
+ [[package]]
1544
+ name = "windows_aarch64_gnullvm"
1545
+ version = "0.52.6"
1546
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1547
+ checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
1548
+
1549
+ [[package]]
1550
+ name = "windows_aarch64_msvc"
1551
+ version = "0.52.6"
1552
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1553
+ checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
1554
+
1555
+ [[package]]
1556
+ name = "windows_i686_gnu"
1557
+ version = "0.52.6"
1558
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1559
+ checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
1560
+
1561
+ [[package]]
1562
+ name = "windows_i686_gnullvm"
1563
+ version = "0.52.6"
1564
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1565
+ checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
1566
+
1567
+ [[package]]
1568
+ name = "windows_i686_msvc"
1569
+ version = "0.52.6"
1570
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1571
+ checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
1572
+
1573
+ [[package]]
1574
+ name = "windows_x86_64_gnu"
1575
+ version = "0.52.6"
1576
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1577
+ checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
1578
+
1579
+ [[package]]
1580
+ name = "windows_x86_64_gnullvm"
1581
+ version = "0.52.6"
1582
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1583
+ checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
1584
+
1585
+ [[package]]
1586
+ name = "windows_x86_64_msvc"
1587
+ version = "0.52.6"
1588
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1589
+ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
1590
+
1372
1591
  [[package]]
1373
1592
  name = "wit-bindgen"
1374
1593
  version = "0.51.0"
@@ -1477,6 +1696,12 @@ dependencies = [
1477
1696
  "syn",
1478
1697
  ]
1479
1698
 
1699
+ [[package]]
1700
+ name = "zeroize"
1701
+ version = "1.8.2"
1702
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1703
+ checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0"
1704
+
1480
1705
  [[package]]
1481
1706
  name = "zmij"
1482
1707
  version = "1.0.21"
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "rsloop"
3
- version = "0.1.3"
3
+ version = "0.1.4"
4
4
  edition = "2021"
5
5
  description = "An event loop for asyncio written in Rust"
6
6
  license = "Apache-2.0"
@@ -18,12 +18,15 @@ default = []
18
18
  profiler = ["dep:pprof"]
19
19
 
20
20
  [dependencies]
21
+ async-std = "1"
21
22
  crossbeam-channel = "0.5"
22
23
  futures = { version = "0.3", default-features = false, features = ["std"] }
23
24
  libc = "0.2"
24
25
  pprof = { version = "0.15.0", default-features = false, features = ["flamegraph"], optional = true }
25
26
  pyo3 = { version = "0.28", features = ["extension-module"] }
26
27
  pyo3-async-runtimes = { version = "0.28", features = ["async-std-runtime"] }
28
+ rustls = "0.23"
29
+ rustls-pemfile = "2"
27
30
  signal-hook = "0.4"
28
31
  socket2 = "0.6"
29
32
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rsloop
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Classifier: Development Status :: 3 - Alpha
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: Apache Software License
@@ -182,11 +182,6 @@ level transport code in `src/stream_transport.rs`.
182
182
 
183
183
  These gaps are visible in the current implementation.
184
184
 
185
- - TLS is not implemented.
186
- - `start_tls()` is stubbed.
187
- - `ssl=...` is rejected for `create_server`, `create_connection`,
188
- `create_unix_server`, `create_unix_connection`, and
189
- `connect_accepted_socket`.
190
185
  - Stream transport flow control is partial:
191
186
  `pause_reading()` and `resume_reading()` work, but
192
187
  `get_write_buffer_size()` returns `0`,
@@ -194,9 +189,13 @@ These gaps are visible in the current implementation.
194
189
  `set_write_buffer_limits()` is a no-op.
195
190
  - Several compatibility parameters are currently accepted only to preserve API
196
191
  shape, not to provide full behavior:
197
- `server_hostname`, `happy_eyeballs_delay`, `interleave`, `all_errors`,
198
- `ssl_handshake_timeout`, `ssl_shutdown_timeout`, and
192
+ `happy_eyeballs_delay`, `interleave`, `all_errors`,
193
+ `ssl_shutdown_timeout`, and
199
194
  `shutdown_default_executor(timeout=...)`.
195
+ - TLS uses a `rustls` backend with a narrower compatibility surface than
196
+ CPython's OpenSSL-backed `ssl` module. In particular, encrypted private keys
197
+ are not supported yet, and the fast-stream monkeypatch still falls back to
198
+ stdlib helpers whenever `ssl` is enabled.
200
199
  - Subprocess support is intentionally incomplete:
201
200
  `preexec_fn` is unsupported, and text mode is rejected for
202
201
  `asyncio.create_subprocess_exec()` /
@@ -150,11 +150,6 @@ level transport code in `src/stream_transport.rs`.
150
150
 
151
151
  These gaps are visible in the current implementation.
152
152
 
153
- - TLS is not implemented.
154
- - `start_tls()` is stubbed.
155
- - `ssl=...` is rejected for `create_server`, `create_connection`,
156
- `create_unix_server`, `create_unix_connection`, and
157
- `connect_accepted_socket`.
158
153
  - Stream transport flow control is partial:
159
154
  `pause_reading()` and `resume_reading()` work, but
160
155
  `get_write_buffer_size()` returns `0`,
@@ -162,9 +157,13 @@ These gaps are visible in the current implementation.
162
157
  `set_write_buffer_limits()` is a no-op.
163
158
  - Several compatibility parameters are currently accepted only to preserve API
164
159
  shape, not to provide full behavior:
165
- `server_hostname`, `happy_eyeballs_delay`, `interleave`, `all_errors`,
166
- `ssl_handshake_timeout`, `ssl_shutdown_timeout`, and
160
+ `happy_eyeballs_delay`, `interleave`, `all_errors`,
161
+ `ssl_shutdown_timeout`, and
167
162
  `shutdown_default_executor(timeout=...)`.
163
+ - TLS uses a `rustls` backend with a narrower compatibility surface than
164
+ CPython's OpenSSL-backed `ssl` module. In particular, encrypted private keys
165
+ are not supported yet, and the fast-stream monkeypatch still falls back to
166
+ stdlib helpers whenever `ssl` is enabled.
168
167
  - Subprocess support is intentionally incomplete:
169
168
  `preexec_fn` is unsupported, and text mode is rejected for
170
169
  `asyncio.create_subprocess_exec()` /
rsloop-0.1.4/justfile ADDED
@@ -0,0 +1,4 @@
1
+ set shell := ["bash", "-euo", "pipefail", "-c"]
2
+
3
+ tls-test-certs outdir="tests/fixtures/tls":
4
+ ./scripts/generate-test-tls-certs.sh {{outdir}}
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "rsloop"
7
- version = "0.1.3"
7
+ version = "0.1.4"
8
8
  description = "An event loop for asyncio written in Rust"
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE" }
@@ -3,6 +3,7 @@ from __future__ import annotations
3
3
  import asyncio as __asyncio
4
4
  import contextlib as __contextlib
5
5
  import os as __os
6
+ import ssl as __ssl
6
7
  import sys as __sys
7
8
  import typing as __typing
8
9
 
@@ -98,6 +99,42 @@ if __USE_FAST_STREAMS and __asyncio.start_server is __ORIG_START_SERVER:
98
99
  __asyncio.start_server = __start_server
99
100
 
100
101
 
102
+ def __install_ssl_tracking() -> None:
103
+ context_cls = __ssl.SSLContext
104
+ if getattr(context_cls, "_rsloop_tracking_installed", False):
105
+ return
106
+
107
+ orig_load_cert_chain = context_cls.load_cert_chain
108
+
109
+ def load_cert_chain(self, certfile, keyfile=None, password=None):
110
+ result = orig_load_cert_chain(
111
+ self,
112
+ certfile,
113
+ keyfile=keyfile,
114
+ password=password,
115
+ )
116
+ if callable(password):
117
+ password_value = password()
118
+ else:
119
+ password_value = password
120
+ if isinstance(password_value, str):
121
+ password_value = password_value.encode()
122
+ if password_value is not None and not isinstance(password_value, bytes):
123
+ password_value = bytes(password_value)
124
+ self.__dict__["_rsloop_certfile"] = __os.fspath(certfile)
125
+ self.__dict__["_rsloop_keyfile"] = (
126
+ __os.fspath(keyfile) if keyfile is not None else __os.fspath(certfile)
127
+ )
128
+ self.__dict__["_rsloop_key_password"] = password_value
129
+ return result
130
+
131
+ context_cls.load_cert_chain = load_cert_chain
132
+ context_cls._rsloop_tracking_installed = True
133
+
134
+
135
+ __install_ssl_tracking()
136
+
137
+
101
138
  if __typing.TYPE_CHECKING:
102
139
 
103
140
  def run(
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ outdir="${1:-tests/fixtures/tls}"
5
+
6
+ mkdir -p "${outdir}"
7
+
8
+ cat <<'EOF' > "${outdir}/cert.ext"
9
+ basicConstraints=CA:FALSE
10
+ keyUsage=digitalSignature,keyEncipherment
11
+ extendedKeyUsage=serverAuth
12
+ subjectAltName=DNS:localhost
13
+ EOF
14
+
15
+ openssl req \
16
+ -x509 \
17
+ -newkey rsa:2048 \
18
+ -nodes \
19
+ -keyout "${outdir}/ca-key.pem" \
20
+ -out "${outdir}/ca-cert.pem" \
21
+ -subj /CN=rsloop-test-ca \
22
+ -days 1 \
23
+ >/dev/null 2>&1
24
+
25
+ openssl req \
26
+ -newkey rsa:2048 \
27
+ -nodes \
28
+ -keyout "${outdir}/key.pem" \
29
+ -out "${outdir}/cert.csr" \
30
+ -subj /CN=localhost \
31
+ >/dev/null 2>&1
32
+
33
+ openssl x509 \
34
+ -req \
35
+ -in "${outdir}/cert.csr" \
36
+ -CA "${outdir}/ca-cert.pem" \
37
+ -CAkey "${outdir}/ca-key.pem" \
38
+ -CAcreateserial \
39
+ -out "${outdir}/cert.pem" \
40
+ -days 1 \
41
+ -extfile "${outdir}/cert.ext" \
42
+ >/dev/null 2>&1
43
+
44
+ rm -f "${outdir}/cert.csr" "${outdir}/cert.ext" "${outdir}/ca-cert.srl"
45
+
46
+ echo "Generated TLS test certs in ${outdir}"
@@ -5,6 +5,12 @@ use futures::channel::oneshot;
5
5
  use pyo3::exceptions::PyRuntimeError;
6
6
  use pyo3::prelude::*;
7
7
  #[cfg(windows)]
8
+ use socket2::Socket;
9
+ #[cfg(windows)]
10
+ use std::mem;
11
+ #[cfg(windows)]
12
+ use std::os::windows::io::{FromRawSocket, IntoRawSocket};
13
+ #[cfg(windows)]
8
14
  use windows_sys::Win32::Foundation::{
9
15
  DuplicateHandle, DUPLICATE_SAME_ACCESS, HANDLE, INVALID_HANDLE_VALUE,
10
16
  };
@@ -40,15 +46,31 @@ pub fn dup_raw_fd(fd: RawFd) -> io::Result<RawFd> {
40
46
 
41
47
  #[cfg(windows)]
42
48
  {
43
- let fd = raw_fd_to_c_int(fd)?;
44
- let duped = unsafe { libc::dup(fd) };
45
- if duped < 0 {
46
- return Err(io::Error::last_os_error());
49
+ match duplicate_socket(fd) {
50
+ Ok(duped) => return Ok(duped),
51
+ Err(socket_err) => {
52
+ if let Ok(fd) = raw_fd_to_c_int(fd) {
53
+ let duped = unsafe { libc::dup(fd) };
54
+ if duped >= 0 {
55
+ return Ok(duped as RawFd);
56
+ }
57
+ }
58
+ return Err(socket_err);
59
+ }
47
60
  }
48
- Ok(duped as RawFd)
49
61
  }
50
62
  }
51
63
 
64
+ #[cfg(windows)]
65
+ fn duplicate_socket(fd: RawFd) -> io::Result<RawFd> {
66
+ let socket = raw_fd_to_socket(fd)?;
67
+ let socket = unsafe { Socket::from_raw_socket(socket as _) };
68
+ let duplicate = socket.try_clone()?;
69
+ let raw = duplicate.into_raw_socket();
70
+ mem::forget(socket);
71
+ Ok(raw as RawFd)
72
+ }
73
+
52
74
  #[cfg(windows)]
53
75
  pub fn raw_fd_to_handle(fd: RawFd) -> io::Result<HANDLE> {
54
76
  let fd = raw_fd_to_c_int(fd)?;
@@ -12,6 +12,7 @@ mod python_api;
12
12
  mod python_names;
13
13
  mod runtime;
14
14
  mod stream_transport;
15
+ mod tls;
15
16
 
16
17
  pub use callbacks::{PyHandle, PyTimerHandle, ReadyCallback};
17
18
  pub use fast_streams::{open_connection, start_server, PyFastStreamReader, PyFastStreamWriter};