Skip to content

Commit 36fbbdf

Browse files
committed
feat: Put tokens into Rc
WIP
1 parent d89d9d9 commit 36fbbdf

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

neqo-transport/src/pmtud.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ mod tests {
362362
Some(u16::MAX as usize),
363363
];
364364

365-
const fn make_sent_packet(pn: u64, now: Instant, len: usize) -> sent::Packet {
365+
fn make_sent_packet(pn: u64, now: Instant, len: usize) -> sent::Packet {
366366
sent::Packet::new(
367367
packet::Type::Short,
368368
pn,

neqo-transport/src/recovery/sent.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
// A collection for sent packets.
88

99
use std::{
10-
collections::BTreeMap,
11-
ops::RangeInclusive,
12-
time::{Duration, Instant},
10+
collections::BTreeMap, ops::RangeInclusive, rc::Rc, time::{Duration, Instant}
1311
};
1412

1513
use crate::{packet, recovery};
@@ -21,7 +19,7 @@ pub struct Packet {
2119
ack_eliciting: bool,
2220
time_sent: Instant,
2321
primary_path: bool,
24-
tokens: recovery::Tokens,
22+
tokens: Rc<recovery::Tokens>,
2523

2624
time_declared_lost: Option<Instant>,
2725
/// After a PTO, this is true when the packet has been released.
@@ -32,7 +30,7 @@ pub struct Packet {
3230

3331
impl Packet {
3432
#[must_use]
35-
pub const fn new(
33+
pub fn new(
3634
pt: packet::Type,
3735
pn: packet::Number,
3836
time_sent: Instant,
@@ -46,7 +44,7 @@ impl Packet {
4644
time_sent,
4745
ack_eliciting,
4846
primary_path: true,
49-
tokens,
47+
tokens: Rc::new(tokens),
5048
time_declared_lost: None,
5149
pto: false,
5250
len,
@@ -104,8 +102,8 @@ impl Packet {
104102

105103
/// Access the recovery tokens that this holds.
106104
#[must_use]
107-
pub const fn tokens(&self) -> &recovery::Tokens {
108-
&self.tokens
105+
pub fn tokens(&self) -> &recovery::Tokens {
106+
self.tokens.as_ref()
109107
}
110108

111109
/// Clears the flag that had this packet on the primary path.

0 commit comments

Comments
 (0)