pub(super) struct Resends {
queue: PriorityQueue<PackageId, Timing>,
headers: AHashMap<PackageId, PackageHeader>,
data: DataBuf,
}
Expand description
This struct governs reliable package re-sending (until each package is confirmed).
Fields§
§queue: PriorityQueue<PackageId, Timing>
§headers: AHashMap<PackageId, PackageHeader>
§data: DataBuf
Implementations§
source§impl Resends
impl Resends
pub(super) fn new() -> Self
sourcepub(super) fn push(&mut self, header: PackageHeader, data: &[u8], now: Instant)
pub(super) fn push(&mut self, header: PackageHeader, data: &[u8], now: Instant)
Registers new package for re-sending until it is resolved.
§Panics
-
If the package (ID) is already stored.
-
If data is longer than
MAX_PACKAGE_SIZE
.
sourcepub(super) fn resolve(&mut self, id: PackageId)
pub(super) fn resolve(&mut self, id: PackageId)
Marks a package as delivered. No more re-sends will be scheduled and package data will be dropped.
sourcepub(super) fn reschedule(
&mut self,
buf: &mut [u8],
now: Instant
) -> RescheduleResult
pub(super) fn reschedule( &mut self, buf: &mut [u8], now: Instant ) -> RescheduleResult
Retrieves next package to be resend or None if there is not (yet) such a package.
Each package is resent multiple times with randomized exponential backoff.
§Arguments
-
buf
- the package payload is written to this buffer. The buffer length must be greater or equal to the length of the payload. -
now
- current time, used for the retry scheduling.
§Panics
Panics if buf
is smaller than the retrieved package payload.
Auto Trait Implementations§
impl Freeze for Resends
impl RefUnwindSafe for Resends
impl Send for Resends
impl Sync for Resends
impl Unpin for Resends
impl UnwindSafe for Resends
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