rwebtransport 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/Cargo.lock +666 -0
  2. package/Cargo.toml +31 -0
  3. package/LICENSE +202 -0
  4. package/NOTICE +41 -0
  5. package/README.md +550 -0
  6. package/crates/echo-server/Cargo.toml +20 -0
  7. package/crates/echo-server/src/main.rs +666 -0
  8. package/crates/native/Cargo.toml +23 -0
  9. package/crates/native/src/config.rs +129 -0
  10. package/crates/native/src/driver.rs +463 -0
  11. package/crates/native/src/lib.rs +821 -0
  12. package/crates/native/src/server.rs +718 -0
  13. package/crates/native/src/session.rs +1191 -0
  14. package/crates/native/src/tls.rs +96 -0
  15. package/crates/wtcore/Cargo.toml +15 -0
  16. package/crates/wtcore/src/h3.rs +226 -0
  17. package/crates/wtcore/src/lib.rs +9 -0
  18. package/dist/datagrams.d.ts +16 -0
  19. package/dist/errors.d.ts +10 -0
  20. package/dist/index.d.ts +7 -0
  21. package/dist/index.js +1512 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/index.mjs +1473 -0
  24. package/dist/index.mjs.map +1 -0
  25. package/dist/loader.d.ts +2 -0
  26. package/dist/native.d.ts +226 -0
  27. package/dist/server.d.ts +44 -0
  28. package/dist/streams.d.ts +14 -0
  29. package/dist/types.d.ts +24 -0
  30. package/dist/webtransport.d.ts +20 -0
  31. package/package.json +79 -0
  32. package/prebuilds/win32-x64/rwebtransport.node +0 -0
  33. package/scripts/bench.mjs +180 -0
  34. package/scripts/build.js +67 -0
  35. package/scripts/postinstall.js +67 -0
  36. package/scripts/setup-unix.sh +129 -0
  37. package/scripts/setup-windows.ps1 +229 -0
  38. package/vendor/quiche/AGENTS.md +75 -0
  39. package/vendor/quiche/COPYING +23 -0
  40. package/vendor/quiche/Cargo.lock +1212 -0
  41. package/vendor/quiche/Cargo.toml +215 -0
  42. package/vendor/quiche/README.md +466 -0
  43. package/vendor/quiche/examples/Makefile +46 -0
  44. package/vendor/quiche/examples/README.md +20 -0
  45. package/vendor/quiche/examples/cert-big.crt +90 -0
  46. package/vendor/quiche/examples/cert.crt +18 -0
  47. package/vendor/quiche/examples/cert.key +28 -0
  48. package/vendor/quiche/examples/client.c +343 -0
  49. package/vendor/quiche/examples/client.rs +281 -0
  50. package/vendor/quiche/examples/gen-certs.sh +15 -0
  51. package/vendor/quiche/examples/http3-client.c +473 -0
  52. package/vendor/quiche/examples/http3-client.rs +349 -0
  53. package/vendor/quiche/examples/http3-server.c +614 -0
  54. package/vendor/quiche/examples/http3-server.rs +680 -0
  55. package/vendor/quiche/examples/qpack-decode.rs +87 -0
  56. package/vendor/quiche/examples/qpack-encode.rs +88 -0
  57. package/vendor/quiche/examples/rootca.crt +21 -0
  58. package/vendor/quiche/examples/server.c +529 -0
  59. package/vendor/quiche/examples/server.rs +529 -0
  60. package/vendor/quiche/include/quiche.h +1282 -0
  61. package/vendor/quiche/quiche.svg +1 -0
  62. package/vendor/quiche/src/buffers.rs +105 -0
  63. package/vendor/quiche/src/build.rs +66 -0
  64. package/vendor/quiche/src/cid.rs +1079 -0
  65. package/vendor/quiche/src/crypto/boringssl.rs +373 -0
  66. package/vendor/quiche/src/crypto/mod.rs +671 -0
  67. package/vendor/quiche/src/dgram.rs +118 -0
  68. package/vendor/quiche/src/error.rs +263 -0
  69. package/vendor/quiche/src/ffi.rs +2290 -0
  70. package/vendor/quiche/src/flowcontrol.rs +246 -0
  71. package/vendor/quiche/src/frame.rs +2172 -0
  72. package/vendor/quiche/src/h3/AGENTS.md +54 -0
  73. package/vendor/quiche/src/h3/ffi.rs +442 -0
  74. package/vendor/quiche/src/h3/frame.rs +1404 -0
  75. package/vendor/quiche/src/h3/mod.rs +8223 -0
  76. package/vendor/quiche/src/h3/qpack/decoder.rs +288 -0
  77. package/vendor/quiche/src/h3/qpack/encoder.rs +235 -0
  78. package/vendor/quiche/src/h3/qpack/mod.rs +202 -0
  79. package/vendor/quiche/src/h3/qpack/static_table.rs +323 -0
  80. package/vendor/quiche/src/h3/stream.rs +1595 -0
  81. package/vendor/quiche/src/lib.rs +9556 -0
  82. package/vendor/quiche/src/minmax.rs +446 -0
  83. package/vendor/quiche/src/packet.rs +2334 -0
  84. package/vendor/quiche/src/path.rs +1374 -0
  85. package/vendor/quiche/src/pmtud.rs +652 -0
  86. package/vendor/quiche/src/rand.rs +64 -0
  87. package/vendor/quiche/src/range_buf.rs +186 -0
  88. package/vendor/quiche/src/ranges.rs +755 -0
  89. package/vendor/quiche/src/recovery/AGENTS.md +80 -0
  90. package/vendor/quiche/src/recovery/bandwidth.rs +565 -0
  91. package/vendor/quiche/src/recovery/bytes_in_flight.rs +179 -0
  92. package/vendor/quiche/src/recovery/congestion/cubic.rs +1038 -0
  93. package/vendor/quiche/src/recovery/congestion/delivery_rate.rs +514 -0
  94. package/vendor/quiche/src/recovery/congestion/hystart.rs +241 -0
  95. package/vendor/quiche/src/recovery/congestion/mod.rs +361 -0
  96. package/vendor/quiche/src/recovery/congestion/prr.rs +238 -0
  97. package/vendor/quiche/src/recovery/congestion/recovery.rs +1170 -0
  98. package/vendor/quiche/src/recovery/congestion/reno.rs +291 -0
  99. package/vendor/quiche/src/recovery/congestion/test_sender.rs +201 -0
  100. package/vendor/quiche/src/recovery/gcongestion/bbr/bandwidth_sampler.rs +1947 -0
  101. package/vendor/quiche/src/recovery/gcongestion/bbr/windowed_filter.rs +158 -0
  102. package/vendor/quiche/src/recovery/gcongestion/bbr.rs +37 -0
  103. package/vendor/quiche/src/recovery/gcongestion/bbr2/drain.rs +120 -0
  104. package/vendor/quiche/src/recovery/gcongestion/bbr2/mode.rs +318 -0
  105. package/vendor/quiche/src/recovery/gcongestion/bbr2/network_model.rs +784 -0
  106. package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_bw.rs +729 -0
  107. package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_rtt.rs +175 -0
  108. package/vendor/quiche/src/recovery/gcongestion/bbr2/startup.rs +190 -0
  109. package/vendor/quiche/src/recovery/gcongestion/bbr2.rs +855 -0
  110. package/vendor/quiche/src/recovery/gcongestion/mod.rs +275 -0
  111. package/vendor/quiche/src/recovery/gcongestion/pacer.rs +294 -0
  112. package/vendor/quiche/src/recovery/gcongestion/recovery.rs +1384 -0
  113. package/vendor/quiche/src/recovery/mod.rs +3086 -0
  114. package/vendor/quiche/src/recovery/rtt.rs +152 -0
  115. package/vendor/quiche/src/stream/mod.rs +2210 -0
  116. package/vendor/quiche/src/stream/recv_buf.rs +1236 -0
  117. package/vendor/quiche/src/stream/send_buf.rs +849 -0
  118. package/vendor/quiche/src/test_utils.rs +681 -0
  119. package/vendor/quiche/src/tests.rs +12922 -0
  120. package/vendor/quiche/src/tls/boringssl.rs +375 -0
  121. package/vendor/quiche/src/tls/mod.rs +1245 -0
  122. package/vendor/quiche/src/transport_params.rs +628 -0
@@ -0,0 +1 @@
1
+ <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 2469 414"><defs><style>.cls-1{fill:#f48120;}.cls-2{fill:#edf2f8;stroke:#bfcce2;stroke-miterlimit:10;}.cls-16,.cls-19,.cls-2{stroke-width:3px;}.cls-3{fill:#d9e4f4;}.cls-4{fill:url(#New_Gradient_Swatch_10);}.cls-5{fill:url(#linear-gradient);}.cls-6{fill:#ffdb6f;}.cls-7{fill:#f16975;}.cls-8{fill:url(#linear-gradient-2);}.cls-9{fill:#e04e64;}.cls-10{fill:url(#linear-gradient-3);}.cls-11{fill:url(#linear-gradient-4);}.cls-12{fill:url(#linear-gradient-5);}.cls-13{fill:url(#linear-gradient-6);}.cls-14{fill:url(#linear-gradient-7);}.cls-15{fill:#f58220;}.cls-16,.cls-19{fill:none;stroke-linecap:round;stroke-linejoin:round;}.cls-16{stroke:url(#linear-gradient-8);}.cls-17{fill:url(#linear-gradient-9);}.cls-18{fill:url(#linear-gradient-10);}.cls-19{stroke:url(#linear-gradient-11);}</style><linearGradient id="New_Gradient_Swatch_10" x1="4197.72" y1="124.27" x2="4512.45" y2="124.27" gradientTransform="translate(-2800.79)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#f48120"/><stop offset="1" stop-color="#ffcc32"/></linearGradient><linearGradient id="linear-gradient" x1="-552" y1="199.14" x2="-231.66" y2="199.14" gradientTransform="matrix(-1, 0, 0, 1, 1164.62, 0)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#ffcc32"/><stop offset="1" stop-color="#f48120"/></linearGradient><linearGradient id="linear-gradient-2" x1="-3038.1" y1="2486.22" x2="-3000.4" y2="2486.22" gradientTransform="translate(34.41 3798.56) rotate(153.05)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#76c4e2"/><stop offset="0.17" stop-color="#85cba8"/></linearGradient><linearGradient id="linear-gradient-3" x1="3051.9" y1="3317.56" x2="3089.59" y2="3317.56" gradientTransform="translate(-1986.07 3186.57) rotate(-88.39)" xlink:href="#linear-gradient-2"/><linearGradient id="linear-gradient-4" x1="1834.7" y1="1037.18" x2="1872.41" y2="1037.18" gradientTransform="translate(3362.56 1038.67) rotate(174.9)" xlink:href="#linear-gradient-2"/><linearGradient id="linear-gradient-5" x1="970.49" y1="5629.27" x2="1046.27" y2="5629.27" gradientTransform="matrix(-0.78, -1.2, 0.67, -0.43, -1300.03, 3843.89)" xlink:href="#linear-gradient-2"/><linearGradient id="linear-gradient-6" x1="-1218.8" y1="4678.97" x2="-1195.56" y2="4678.97" gradientTransform="matrix(-1.43, -0.05, 0.03, -0.79, -289.08, 3840.43)" xlink:href="#linear-gradient-2"/><linearGradient id="linear-gradient-7" x1="696.71" y1="3496.3" x2="740.46" y2="3496.3" gradientTransform="matrix(-0.96, -1.06, 1.11, -1.01, -1716.58, 4495.9)" xlink:href="#linear-gradient-2"/><linearGradient id="linear-gradient-8" x1="-381.86" y1="-813.78" x2="-310.73" y2="-813.78" gradientTransform="matrix(-0.87, -0.49, -0.49, 0.87, 805.63, 652.35)" gradientUnits="userSpaceOnUse"><stop offset="0.46" stop-color="#85cba8"/><stop offset="1" stop-color="#ffdb6f"/></linearGradient><linearGradient id="linear-gradient-9" x1="-351.56" y1="104.87" x2="-307.87" y2="104.87" gradientTransform="matrix(-1, 0, 0, 1, 1164.62, 0)" xlink:href="#linear-gradient-8"/><linearGradient id="linear-gradient-10" x1="2312.2" y1="891.63" x2="2401.76" y2="891.63" gradientTransform="matrix(0.54, 1.61, -1.41, 0.47, 1468.85, -4071.66)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#85cba8"/><stop offset="0.54" stop-color="#76c4e2"/></linearGradient><linearGradient id="linear-gradient-11" x1="-428.03" y1="-475.26" x2="-333.03" y2="-475.26" gradientTransform="matrix(-0.94, -0.34, -0.34, 0.94, 969.14, 440.86)" xlink:href="#linear-gradient-8"/></defs><title>quiche banner</title><path class="cls-1" d="M817.5,193.45q0,17.33-6.15,29.05a37.54,37.54,0,0,1-18,17.16L817,266.06H790.29l-18-22h-1.54q-22.57,0-34.66-13.1T724,193.31q0-24.51,12.12-37.44t34.76-12.93q22.64,0,34.63,13T817.5,193.45Zm-71.67,0q0,16.45,6.25,24.78t18.67,8.33q24.91,0,24.92-33.11t-24.79-33.18q-12.42,0-18.74,8.36T745.83,193.45Z"/><path class="cls-1" d="M937,144.48V208a36.69,36.69,0,0,1-4.87,19.08,31.74,31.74,0,0,1-14.07,12.56Q908.89,244,896.33,244q-18.93,0-29.42-9.71t-10.47-26.57V144.48h20.75V204.6q0,11.35,4.57,16.66t15.11,5.3q10.21,0,14.81-5.34t4.6-16.76v-60Z"/><path class="cls-1" d="M980.34,242.68v-98.2h20.82v98.2Z"/><path class="cls-1" d="M1086.85,160.4q-11.76,0-18.2,8.83t-6.45,24.62q0,32.85,24.65,32.85,10.35,0,25.05-5.18V239a69.54,69.54,0,0,1-27,5q-21.42,0-32.77-13t-11.36-37.31q0-15.32,5.58-26.84a40.27,40.27,0,0,1,16-17.66q10.44-6.15,24.48-6.15A66.12,66.12,0,0,1,1115.6,150l-6.72,16.93a110.14,110.14,0,0,0-11.08-4.57A33.06,33.06,0,0,0,1086.85,160.4Z"/><path class="cls-1" d="M1232.52,242.68h-20.76V200.3h-38.89v42.38h-20.82v-98.2h20.82V183h38.89V144.48h20.76Z"/><path class="cls-1" d="M1333.12,242.68h-56.56v-98.2h56.56v17.06h-35.74V183.1h33.25v17.06h-33.25v25.33h35.74Z"/><path class="cls-2" d="M1327.19,237.32c0-31.85,102.13-57.68,228.12-57.68s228.11,25.83,228.11,57.68S1681.29,295,1555.31,295,1327.19,269.18,1327.19,237.32Z"/><path class="cls-3" d="M1375.85,231.87c0-23.15,80.34-41.92,179.46-41.92s179.46,18.77,179.46,41.92-80.35,41.92-179.46,41.92S1375.85,255,1375.85,231.87Z"/><path class="cls-4" d="M1463.59,87.38c-25.85,16.48-65.06,34.26-65.21,63.88a3.22,3.22,0,0,0,0,5.4c.21,2.54,1.55,4.51,3.18,4.51h306.84c1.78,0,3.23-3.4,3.23-6.27C1711.66,153.39,1463.59,87.38,1463.59,87.38Z"/><path class="cls-5" d="M1709.87,244H1400.75c-4.13-.05-4.13-3.05-4.13-7.05l-.35-82.61h313.6c3.75.65,6.75,1.25,6.75,9.65l-.28,64.81C1716.34,237.16,1713.44,244,1709.87,244Z"/><path class="cls-6" d="M1716,237.32H1408.39c-3.5,0-4.77-.4-4.34-4.91V161.17h311c3.5,0,2.33,5.78,2.33,12.91v50.33C1717.34,231.54,1719.51,237.32,1716,237.32Z"/><path class="cls-7" d="M1536.62,189.09l4.81-3.72a7.36,7.36,0,0,0,1.53-10.05h0a7.37,7.37,0,0,0-10.54-1.6l-4.81,3.72a7.36,7.36,0,0,0-1.52,10.05h0A7.37,7.37,0,0,0,1536.62,189.09Z"/><path class="cls-8" d="M1601.14,217.3a5.51,5.51,0,0,0,.38.67l.17-.08c4.63-2.35,13-10.74,12-15.6a8.32,8.32,0,0,0-2.93.85C1606.73,205.16,1599.11,213.31,1601.14,217.3Z"/><path class="cls-7" d="M1580,230.17l2.57-2a3.93,3.93,0,0,0,.82-5.37h0a3.94,3.94,0,0,0-5.63-.85l-2.57,2a3.93,3.93,0,0,0-.81,5.37h0A3.93,3.93,0,0,0,1580,230.17Z"/><path class="cls-7" d="M1448.87,233.57l4.08-3.15a6.23,6.23,0,0,0,1.29-8.51h0a6.24,6.24,0,0,0-8.92-1.35l-4.08,3.15a6.23,6.23,0,0,0-1.29,8.51h0A6.24,6.24,0,0,0,1448.87,233.57Z"/><path class="cls-9" d="M1702.46,173.07l-2.6-2.49a4.38,4.38,0,0,0-6,0h0a4.37,4.37,0,0,0,0,6.3l2.61,2.49a4.36,4.36,0,0,0,6,0h0A4.37,4.37,0,0,0,1702.46,173.07Z"/><path class="cls-10" d="M1412.81,210.52a6.77,6.77,0,0,0-.78,0,1.09,1.09,0,0,1,0,.18c-.14,5.19,3.25,16.52,8,17.95a8.11,8.11,0,0,0,.66-3C1420.8,221.23,1417.28,210.65,1412.81,210.52Z"/><path class="cls-11" d="M1424.7,174.16c0,.26.07.51.11.76h.19c5.17-.46,16-5.15,16.9-10a8.24,8.24,0,0,0-3-.31C1434.41,165,1424.31,169.7,1424.7,174.16Z"/><path class="cls-12" d="M1660.8,194.72a8.1,8.1,0,0,0-1,.77l.29.45c8.15,12.53,30.76,36.37,39.21,35.34a39.34,39.34,0,0,0-3.93-7.72C1688.37,212.77,1666.79,190.82,1660.8,194.72Z"/><path class="cls-13" d="M1577.87,187.56a1.62,1.62,0,0,0,0,.38h.16c4.58.17,14.55-1.28,15.79-3.58a12.72,12.72,0,0,0-2.63-.38C1587.27,183.84,1578,185.37,1577.87,187.56Z"/><path class="cls-14" d="M1485.56,207.57c-.34.31-.65.63-1,1,.07.08.13.16.2.23,5.8,6.4,23.13,15.87,30.77,11.87a12.9,12.9,0,0,0-2.59-4.36C1508,210.77,1491.35,202.33,1485.56,207.57Z"/><ellipse class="cls-15" cx="1390.66" cy="150.32" rx="10.9" ry="10.89"/><ellipse class="cls-15" cx="1396.27" cy="134.17" rx="10.9" ry="10.89"/><ellipse class="cls-15" cx="1408.48" cy="121.06" rx="10.9" ry="10.89"/><ellipse class="cls-15" cx="1420.69" cy="109.17" rx="10.9" ry="10.89"/><ellipse class="cls-15" cx="1433.33" cy="100.14" rx="10.9" ry="10.89"/><ellipse class="cls-15" cx="1446.62" cy="91.61" rx="10.9" ry="10.89"/><ellipse class="cls-15" cx="1460.45" cy="84.01" rx="10.9" ry="10.89"/><path class="cls-16" d="M1542.75,124.21c-2.68,1.17-19.12,8-37.48,0s-24.43-24.42-25.43-27.2"/><path class="cls-17" d="M1513,128.76a30.44,30.44,0,0,0,3.21-.68c0-.3-.07-.6-.12-.9-3.84-24.83-21.82-43.44-42.84-46.56a43.76,43.76,0,0,0-.2,14.69C1476.32,116.69,1494.21,131.67,1513,128.76Z"/><path class="cls-18" d="M1497.7,140.12a43.67,43.67,0,0,0,4.12-1.65c-.13-.39-.23-.77-.36-1.16-10.76-32.18-38.92-52.87-67.6-52.26a59.17,59.17,0,0,0,3.06,19.59C1446.18,132.35,1473.39,148.23,1497.7,140.12Z"/><path class="cls-19" d="M1536.32,127.3c-3.31,2.17-23.63,15-49.88,8.52-26.06-6.42-38.08-27-40-30.43"/><path class="cls-1" d="M1438.55,284.29a3.24,3.24,0,0,0-3.78-.87c-12.25,4.9-24.16,10.25-36.15,15.18-6,2.46-12,4.84-18.14,7s-12.24,4.1-18.45,5.71a164.22,164.22,0,0,1-18.78,3.76,129.46,129.46,0,0,1-18.94,1.22c-1.83,0-3.65-.08-5.45-.18a152.16,152.16,0,0,0,40-7.27c6.5-2,12.78-4.44,18.88-7s12.06-5.36,17.87-8.27c11.65-5.78,22.82-12,34.09-18a2.21,2.21,0,0,0,1-3.27,3.27,3.27,0,0,0-3.79-.86c-12.11,4.84-23.9,10.13-35.75,15-6,2.44-11.93,4.79-17.94,6.94-3,1.06-6,2.09-9.08,3s-6.09,1.86-9.16,2.68a144.77,144.77,0,0,1-37.29,5.19c-1.56,0-3.14,0-4.69-.08l-2-.1c.38,0,.76,0,1.15-.06l5.25-.31c1.75-.1,3.47-.37,5.21-.55,3.48-.32,6.88-1,10.29-1.55l1.28-.22,1.26-.28,2.52-.56,2.51-.56,1.25-.29,1.23-.34c3.28-.91,6.58-1.77,9.75-2.85,6.45-2,12.61-4.45,18.67-7s11.93-5.32,17.66-8.22c2.9-1.42,5.73-2.9,8.58-4.36l8.44-4.47,16.73-9h0a2.19,2.19,0,0,0,.93-3.26,3.24,3.24,0,0,0-3.77-.86c-12,4.79-23.67,10-35.41,14.87l-4.42,1.8-4.44,1.74c-2.94,1.19-5.93,2.25-8.89,3.35-6,2.08-12,4.09-18,5.68-3,.88-6.09,1.52-9.14,2.22l-1.15.26-1.15.21-2.31.41-2.3.43-1.15.21-1.16.16c-3.09.4-6.17.89-9.27,1.06-1.54.1-3.09.3-4.63.32l-4.64.11c-1.54.07-3.09,0-4.63-.06l-2.6-.09c1.22,0,2.43-.06,3.65-.12a152.65,152.65,0,0,0,40.48-7.54c6.39-2.06,12.6-4.42,18.62-7s11.89-5.32,17.63-8.21c11.5-5.72,22.55-11.85,33.68-17.78a2.2,2.2,0,0,0,.95-3.26,3.25,3.25,0,0,0-3.78-.87c-12,4.78-23.63,10-35.34,14.85-5.89,2.41-11.78,4.75-17.73,6.88q-4.45,1.61-9,3c-3,1-6,1.84-9,2.69a147.37,147.37,0,0,1-36.85,5.4c-3.08.05-43.67-2.18-57.17-3.19-30.8-2.32-104.77-19.5-198.37-10.5-101.91,9.79-244.3,47.63-247.47,48.43l-.27.08h0a2.4,2.4,0,0,0-1.77,2.41c-.08.4-10.75,25,270-29.15,71.68-13.83,172.78.38,172.89.39,6.19.55,26.73,21.56,33.53,27.61,13.72,12.22,38,12.16,45.06,12a150.48,150.48,0,0,0,41.6-7.1,203.22,203.22,0,0,0,19.14-7q9.27-3.92,18.08-8.34c11.79-5.84,23.09-12.11,34.48-18.18A2.2,2.2,0,0,0,1438.55,284.29Z"/></svg>
@@ -0,0 +1,105 @@
1
+ // Copyright (C) 2026, Cloudflare, Inc.
2
+ // All rights reserved.
3
+ //
4
+ // Redistribution and use in source and binary forms, with or without
5
+ // modification, are permitted provided that the following conditions are
6
+ // met:
7
+ //
8
+ // * Redistributions of source code must retain the above copyright notice,
9
+ // this list of conditions and the following disclaimer.
10
+ //
11
+ // * Redistributions in binary form must reproduce the above copyright
12
+ // notice, this list of conditions and the following disclaimer in the
13
+ // documentation and/or other materials provided with the distribution.
14
+ //
15
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
16
+ // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
17
+ // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18
+ // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
19
+ // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20
+ // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21
+ // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22
+ // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
+ // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24
+ // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
+ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+
27
+ use std::fmt::Debug;
28
+ use std::sync::Arc;
29
+
30
+ /// A trait for providing internal storage buffers for streams,
31
+ /// enabling zero-copy operations.
32
+ /// The associated type `Buf` can be any type that dereferences to
33
+ /// a slice, but should be fast to clone, eg. by wrapping it with an
34
+ /// [`Arc`].
35
+ pub trait BufFactory: Clone + Default + Debug {
36
+ /// The type of the generated buffer. The clone operation should be cheap,
37
+ /// e.g., by using an [`Arc`].
38
+ type Buf: Clone + Debug + AsRef<[u8]>;
39
+
40
+ /// The type of generated buffers used for datagrams. These do not need to
41
+ /// be cloneable.
42
+ type DgramBuf: AsRef<[u8]> + From<Vec<u8>>;
43
+
44
+ /// Generate a new buffer from a given slice, the buffer must contain the
45
+ /// same data as the original slice.
46
+ fn buf_from_slice(buf: &[u8]) -> Self::Buf;
47
+
48
+ /// Generate a new datagram buffer from a given slice, the buffer must
49
+ /// contain the same data as the original slice.
50
+ fn dgram_buf_from_slice(buf: &[u8]) -> Self::DgramBuf;
51
+ }
52
+
53
+ /// A trait that enables zero-copy sends to quiche. When buffers produced
54
+ /// by the `BufFactory` implement this trait, quiche and h3 can supply the
55
+ /// raw buffers to be sent, instead of slices that must be copied first.
56
+ pub trait BufSplit {
57
+ /// Split the buffer at a given point, after the split the old buffer
58
+ /// must only contain the first `at` bytes, while the newly produced
59
+ /// buffer must containt the remaining bytes.
60
+ fn split_at(&mut self, at: usize) -> Self;
61
+
62
+ /// Try to prepend a prefix to the buffer, return true if succeeded.
63
+ fn try_add_prefix(&mut self, _prefix: &[u8]) -> bool {
64
+ false
65
+ }
66
+ }
67
+
68
+ /// The default [`BufFactory`] allocates buffers on the heap on demand.
69
+ #[derive(Debug, Clone, Default)]
70
+ pub struct DefaultBufFactory;
71
+
72
+ /// The default [`BufFactory::Buf`] is a boxed slice wrapped in an [`Arc`].
73
+ #[derive(Debug, Clone, Default)]
74
+ pub struct DefaultBuf(Arc<[u8]>);
75
+
76
+ impl BufFactory for DefaultBufFactory {
77
+ type Buf = DefaultBuf;
78
+ type DgramBuf = Vec<u8>;
79
+
80
+ fn buf_from_slice(buf: &[u8]) -> DefaultBuf {
81
+ DefaultBuf(Arc::from(buf))
82
+ }
83
+
84
+ fn dgram_buf_from_slice(buf: &[u8]) -> Vec<u8> {
85
+ buf.into()
86
+ }
87
+ }
88
+
89
+ impl AsRef<[u8]> for DefaultBuf {
90
+ fn as_ref(&self) -> &[u8] {
91
+ &self.0
92
+ }
93
+ }
94
+
95
+ impl BufSplit for bytes::Bytes {
96
+ fn split_at(&mut self, at: usize) -> Self {
97
+ self.split_off(at)
98
+ }
99
+ }
100
+
101
+ impl BufSplit for bytes::BytesMut {
102
+ fn split_at(&mut self, at: usize) -> Self {
103
+ self.split_off(at)
104
+ }
105
+ }
@@ -0,0 +1,66 @@
1
+ fn write_pkg_config() {
2
+ use std::io::prelude::*;
3
+
4
+ let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
5
+ let target_dir = target_dir_path();
6
+
7
+ let out_path = target_dir.as_path().join("quiche.pc");
8
+ let mut out_file = std::fs::File::create(out_path).unwrap();
9
+
10
+ let include_dir = format!("{manifest_dir}/include");
11
+
12
+ let version = std::env::var("CARGO_PKG_VERSION").unwrap();
13
+
14
+ let output = format!(
15
+ "# quiche
16
+
17
+ includedir={include_dir}
18
+ libdir={}
19
+
20
+ Name: quiche
21
+ Description: quiche library
22
+ URL: https://github.com/cloudflare/quiche
23
+ Version: {version}
24
+ Libs: -Wl,-rpath,${{libdir}} -L${{libdir}} -lquiche
25
+ Cflags: -I${{includedir}}
26
+ ",
27
+ target_dir.to_str().unwrap(),
28
+ );
29
+
30
+ out_file.write_all(output.as_bytes()).unwrap();
31
+ }
32
+
33
+ fn target_dir_path() -> std::path::PathBuf {
34
+ let out_dir = std::env::var("OUT_DIR").unwrap();
35
+ let out_dir = std::path::Path::new(&out_dir);
36
+
37
+ for p in out_dir.ancestors() {
38
+ if p.ends_with("build") {
39
+ return p.parent().unwrap().to_path_buf();
40
+ }
41
+ }
42
+
43
+ unreachable!();
44
+ }
45
+
46
+ fn main() {
47
+ if cfg!(feature = "boringssl-boring-crate") {
48
+ println!("cargo:rustc-link-lib=static=ssl");
49
+ println!("cargo:rustc-link-lib=static=crypto");
50
+ }
51
+
52
+ // MacOS: Allow cdylib to link with undefined symbols
53
+ let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
54
+ if target_os == "macos" {
55
+ println!("cargo:rustc-cdylib-link-arg=-Wl,-undefined,dynamic_lookup");
56
+ }
57
+
58
+ if cfg!(feature = "pkg-config-meta") {
59
+ write_pkg_config();
60
+ }
61
+
62
+ #[cfg(feature = "ffi")]
63
+ if target_os != "windows" {
64
+ cdylib_link_lines::metabuild();
65
+ }
66
+ }