Skip to content

Commit 8d60a9b

Browse files
committed
Introduce TransmitBuilder::has_datagram_capacity
Replaces manually checking for number of allowed datagrams.
1 parent 03afc05 commit 8d60a9b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

quinn-proto/src/connection/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ impl Connection {
565565
// We need to send 1 more datagram and extend the buffer for that.
566566

567567
// Is 1 more datagram allowed?
568-
if transmit.num_datagrams() >= transmit.max_datagrams() {
568+
if transmit.has_datagram_capacity() {
569569
// No more datagrams allowed
570570
break;
571571
}

quinn-proto/src/connection/transmit_builder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ impl<'a> TransmitBuilder<'a> {
160160
&self.buf[self.datagram_start..]
161161
}
162162

163+
/// Whether there is space for another datagram in this transmit
164+
pub(super) fn has_datagram_capacity(&self) -> bool {
165+
self.num_datagrams >= self.max_datagrams
166+
}
167+
163168
/// Returns the GSO segment size
164169
///
165170
/// This is also the maximum size datagrams are allowed to be. The first and last
@@ -176,11 +181,6 @@ impl<'a> TransmitBuilder<'a> {
176181
self.num_datagrams
177182
}
178183

179-
/// Returns the maximum number of datagrams allowed to be written into the buffer
180-
pub(super) fn max_datagrams(&self) -> usize {
181-
self.max_datagrams
182-
}
183-
184184
/// Returns `true` if there are no datagrams in this transmit
185185
pub(super) fn is_empty(&self) -> bool {
186186
self.len() == 0

0 commit comments

Comments
 (0)