7
7
// A collection for sent packets.
8
8
9
9
use std:: {
10
- collections:: BTreeMap ,
11
- ops:: RangeInclusive ,
12
- time:: { Duration , Instant } ,
10
+ collections:: BTreeMap , ops:: RangeInclusive , rc:: Rc , time:: { Duration , Instant }
13
11
} ;
14
12
15
13
use crate :: { packet, recovery} ;
@@ -21,7 +19,7 @@ pub struct Packet {
21
19
ack_eliciting : bool ,
22
20
time_sent : Instant ,
23
21
primary_path : bool ,
24
- tokens : recovery:: Tokens ,
22
+ tokens : Rc < recovery:: Tokens > ,
25
23
26
24
time_declared_lost : Option < Instant > ,
27
25
/// After a PTO, this is true when the packet has been released.
@@ -32,7 +30,7 @@ pub struct Packet {
32
30
33
31
impl Packet {
34
32
#[ must_use]
35
- pub const fn new (
33
+ pub fn new (
36
34
pt : packet:: Type ,
37
35
pn : packet:: Number ,
38
36
time_sent : Instant ,
@@ -46,7 +44,7 @@ impl Packet {
46
44
time_sent,
47
45
ack_eliciting,
48
46
primary_path : true ,
49
- tokens,
47
+ tokens : Rc :: new ( tokens ) ,
50
48
time_declared_lost : None ,
51
49
pto : false ,
52
50
len,
@@ -104,8 +102,8 @@ impl Packet {
104
102
105
103
/// Access the recovery tokens that this holds.
106
104
#[ 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 ( )
109
107
}
110
108
111
109
/// Clears the flag that had this packet on the primary path.
0 commit comments