Skip to content

Commit 7d9c0e4

Browse files
authored
Merge branch 'main' into fix-send-buffer
2 parents 31af5f7 + 1b96a5f commit 7d9c0e4

File tree

30 files changed

+900
-555
lines changed

30 files changed

+900
-555
lines changed

.github/workflows/tests.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ jobs:
170170
# Using self-hosted runners so use local cache for sccache and
171171
# not SCCACHE_GHA_ENABLED.
172172
RUSTC_WRAPPER: "sccache"
173+
# Force clang/bindgen to use MSVC target to avoid mingw headers from msys2
174+
BINDGEN_EXTRA_CLANG_ARGS: "--target=x86_64-pc-windows-msvc"
173175
steps:
174176
- name: Checkout
175177
uses: actions/checkout@v6
@@ -274,6 +276,9 @@ jobs:
274276
echo "C:\Program Files\LLVM\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
275277
echo "LIBCLANG_PATH=C:\Program Files\LLVM\bin" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
276278
279+
- name: Setup MSVC dev environment
280+
uses: ilammy/msvc-dev-cmd@v1
281+
277282
- name: build tests
278283
run: |
279284
cargo nextest run --workspace --exclude fuzz ${{ env.FEATURES }} --lib --bins --tests --target ${{ matrix.target }} --no-run

quinn-proto/src/cid_queue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct CidData(ConnectionId, Option<ResetToken>);
1414
/// - Zero to `Self::LEN - 1` reserved CIDs from `self.cursor` up to `self.cursor_reserved`.
1515
/// - More "available"/"ready" CIDs after `self.cursor_reserved`.
1616
///
17-
/// The range of reserved CIDs is grown by calling [`CidQueue::next_reserved`], which takes one of
17+
/// The range of reserved CIDs is grown by calling `CidQueue::next_reserved`, which takes one of
1818
/// the available ones and returns the CID that was reserved.
1919
///
2020
/// New available/ready CIDs are added by calling [`CidQueue::insert`].

quinn-proto/src/coding.rs

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,63 +15,75 @@ pub struct UnexpectedEnd;
1515
/// Coding result type
1616
pub type Result<T> = ::std::result::Result<T, UnexpectedEnd>;
1717

18-
/// Infallible encoding and decoding of QUIC primitives
19-
pub trait Codec: Sized {
18+
/// Infallible encoding of QUIC primitives.
19+
pub trait Encodable {
20+
/// Append the encoding of `self` to the provided buffer.
21+
fn encode<B: BufMut>(&self, buf: &mut B);
22+
}
23+
24+
/// Decoding of QUIC primitives.
25+
pub trait Decodable: Sized {
2026
/// Decode a `Self` from the provided buffer, if the buffer is large enough
2127
fn decode<B: Buf>(buf: &mut B) -> Result<Self>;
22-
/// Append the encoding of `self` to the provided buffer
23-
fn encode<B: BufMut>(&self, buf: &mut B);
2428
}
2529

26-
impl Codec for u8 {
30+
impl Decodable for u8 {
2731
fn decode<B: Buf>(buf: &mut B) -> Result<Self> {
2832
if buf.remaining() < 1 {
2933
return Err(UnexpectedEnd);
3034
}
3135
Ok(buf.get_u8())
3236
}
37+
}
38+
impl Encodable for u8 {
3339
fn encode<B: BufMut>(&self, buf: &mut B) {
3440
buf.put_u8(*self);
3541
}
3642
}
3743

38-
impl Codec for u16 {
44+
impl Decodable for u16 {
3945
fn decode<B: Buf>(buf: &mut B) -> Result<Self> {
4046
if buf.remaining() < 2 {
4147
return Err(UnexpectedEnd);
4248
}
4349
Ok(buf.get_u16())
4450
}
51+
}
52+
impl Encodable for u16 {
4553
fn encode<B: BufMut>(&self, buf: &mut B) {
4654
buf.put_u16(*self);
4755
}
4856
}
4957

50-
impl Codec for u32 {
58+
impl Decodable for u32 {
5159
fn decode<B: Buf>(buf: &mut B) -> Result<Self> {
5260
if buf.remaining() < 4 {
5361
return Err(UnexpectedEnd);
5462
}
5563
Ok(buf.get_u32())
5664
}
65+
}
66+
impl Encodable for u32 {
5767
fn encode<B: BufMut>(&self, buf: &mut B) {
5868
buf.put_u32(*self);
5969
}
6070
}
6171

62-
impl Codec for u64 {
72+
impl Decodable for u64 {
6373
fn decode<B: Buf>(buf: &mut B) -> Result<Self> {
6474
if buf.remaining() < 8 {
6575
return Err(UnexpectedEnd);
6676
}
6777
Ok(buf.get_u64())
6878
}
79+
}
80+
impl Encodable for u64 {
6981
fn encode<B: BufMut>(&self, buf: &mut B) {
7082
buf.put_u64(*self);
7183
}
7284
}
7385

74-
impl Codec for Ipv4Addr {
86+
impl Decodable for Ipv4Addr {
7587
fn decode<B: Buf>(buf: &mut B) -> Result<Self> {
7688
if buf.remaining() < 4 {
7789
return Err(UnexpectedEnd);
@@ -80,12 +92,14 @@ impl Codec for Ipv4Addr {
8092
buf.copy_to_slice(&mut octets);
8193
Ok(octets.into())
8294
}
95+
}
96+
impl Encodable for Ipv4Addr {
8397
fn encode<B: BufMut>(&self, buf: &mut B) {
8498
buf.put_slice(&self.octets());
8599
}
86100
}
87101

88-
impl Codec for Ipv6Addr {
102+
impl Decodable for Ipv6Addr {
89103
fn decode<B: Buf>(buf: &mut B) -> Result<Self> {
90104
if buf.remaining() < 16 {
91105
return Err(UnexpectedEnd);
@@ -94,18 +108,20 @@ impl Codec for Ipv6Addr {
94108
buf.copy_to_slice(&mut octets);
95109
Ok(octets.into())
96110
}
111+
}
112+
impl Encodable for Ipv6Addr {
97113
fn encode<B: BufMut>(&self, buf: &mut B) {
98114
buf.put_slice(&self.octets());
99115
}
100116
}
101117

102118
pub(crate) trait BufExt {
103-
fn get<T: Codec>(&mut self) -> Result<T>;
119+
fn get<T: Decodable>(&mut self) -> Result<T>;
104120
fn get_var(&mut self) -> Result<u64>;
105121
}
106122

107123
impl<T: Buf> BufExt for T {
108-
fn get<U: Codec>(&mut self) -> Result<U> {
124+
fn get<U: Decodable>(&mut self) -> Result<U> {
109125
U::decode(self)
110126
}
111127

@@ -115,12 +131,12 @@ impl<T: Buf> BufExt for T {
115131
}
116132

117133
pub(crate) trait BufMutExt {
118-
fn write<T: Codec>(&mut self, x: T);
134+
fn write<T: Encodable>(&mut self, x: T);
119135
fn write_var(&mut self, x: u64);
120136
}
121137

122138
impl<T: BufMut> BufMutExt for T {
123-
fn write<U: Codec>(&mut self, x: U) {
139+
fn write<U: Encodable>(&mut self, x: U) {
124140
x.encode(self);
125141
}
126142

quinn-proto/src/config/qlog.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{ConnectionId, Instant, Side};
1010
///
1111
/// This is set via [`TransportConfig::qlog_factory`].
1212
///
13-
/// [`TransportConfig::qlog_factory]: crate::config::TransportConfig::qlog_factory
13+
/// [`TransportConfig::qlog_factory`]: crate::TransportConfig::qlog_factory
1414
pub trait QlogFactory: Send + Sync + 'static {
1515
/// Returns a [`QlogConfig`] for a connection, if logging should be enabled.
1616
///

0 commit comments

Comments
 (0)