pub struct Map<V> { /* private fields */ }
Expand description
A data structure for tracking packets that are pending acknowledgement
The following assumptions are made and exploited
- Packet numbers are monotonically generated and inserted
- Packet numbers will mostly be removed in ranges
- Packet numbers that are deemed lost will also be removed and retransmitted
This is implemented as a buffer ring with a moving range for the lower and upper bound of contained packet numbers. The following example illustrates how each field tracks state:
ⓘ
packets = [ PN(2), None, PN(0), PN(1) ]
^ index = 2
start = PN(0)
end = PN(2)
Upon inserting PN(3)
the state is now:
ⓘ
packets = [ PN(2), PN(3), PN(0), PN(1) ]
^ index = 2
start = PN(0)
end = PN(3)
Upon removing PN(0)
the state is now:
ⓘ
packets = [ PN(2), PN(3), None, PN(1) ]
^ index = 3
start = PN(1)
end = PN(3)
Implementations§
source§impl<V> Map<V>
impl<V> Map<V>
sourcepub fn insert(&mut self, packet_number: PacketNumber, value: V)
pub fn insert(&mut self, packet_number: PacketNumber, value: V)
Inserts the given value
sourcepub fn insert_or_update<F: FnOnce(&mut V)>(
&mut self,
packet_number: PacketNumber,
value: V,
update: F
)
pub fn insert_or_update<F: FnOnce(&mut V)>( &mut self, packet_number: PacketNumber, value: V, update: F )
Inserts the given value
into the map or updates the existing entry
sourcepub fn get(&self, packet_number: PacketNumber) -> Option<&V>
pub fn get(&self, packet_number: PacketNumber) -> Option<&V>
Returns a reference to the V
associated with the given packet_number
sourcepub fn remove(&mut self, packet_number: PacketNumber) -> Option<V>
pub fn remove(&mut self, packet_number: PacketNumber) -> Option<V>
Removes the value associated with the given packet_number
and returns the value if it was present
sourcepub fn remove_range(&mut self, range: PacketNumberRange) -> RemoveIter<'_, V> ⓘ
pub fn remove_range(&mut self, range: PacketNumberRange) -> RemoveIter<'_, V> ⓘ
Removes a range of packets from the map and returns their value
sourcepub fn get_range(&self) -> PacketNumberRange ⓘ
pub fn get_range(&self) -> PacketNumberRange ⓘ
Get the inclusive PacketNumberRange
Trait Implementations§
Auto Trait Implementations§
impl<V> Freeze for Map<V>
impl<V> RefUnwindSafe for Map<V>where
V: RefUnwindSafe,
impl<V> Send for Map<V>where
V: Send,
impl<V> Sync for Map<V>where
V: Sync,
impl<V> Unpin for Map<V>
impl<V> UnwindSafe for Map<V>where
V: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more