pub struct OutboundTransferState { /* private fields */ }Expand description
Tracks the sliding-window state for a single outbound file transfer.
Instead of sending all chunks at once, this limits the number of in-flight
(unACKed) chunks to max_in_flight, reducing outbox pressure and providing
backpressure that adapts to the transport’s throughput.
Implementations§
Source§impl OutboundTransferState
impl OutboundTransferState
Sourcepub fn new(chunks: Vec<FileChunk>, max_in_flight: usize) -> Self
pub fn new(chunks: Vec<FileChunk>, max_in_flight: usize) -> Self
Creates a new outbound transfer state with the given chunks and window size.
Sourcepub fn next_chunks_to_send(&mut self) -> Vec<FileChunk>
pub fn next_chunks_to_send(&mut self) -> Vec<FileChunk>
Returns the next batch of chunks that can be sent without exceeding the in-flight window. Returned chunks are marked as in-flight.
Sourcepub fn on_chunk_ack(&mut self, chunk_index: u32) -> bool
pub fn on_chunk_ack(&mut self, chunk_index: u32) -> bool
Records that a chunk was ACKed. Returns true if this was an in-flight
chunk (i.e. the window has room for more).
Sourcepub fn on_chunk_failed(&mut self, chunk_index: u32)
pub fn on_chunk_failed(&mut self, chunk_index: u32)
Records that a chunk failed terminally and should not be retried at the window level (the transfer will be aborted by the caller).
Sourcepub fn total_chunks(&self) -> u32
pub fn total_chunks(&self) -> u32
Returns the total number of chunks in this transfer.
Sourcepub fn acked_count(&self) -> u32
pub fn acked_count(&self) -> u32
Returns the number of chunks that have been acknowledged.
Sourcepub fn is_fully_acked(&self) -> bool
pub fn is_fully_acked(&self) -> bool
Returns true when all chunks have been acknowledged.
Sourcepub fn all_sent(&self) -> bool
pub fn all_sent(&self) -> bool
Returns true when all chunks have been sent at least once
(they may still be in flight awaiting ACK).
Sourcepub fn has_capacity(&self) -> bool
pub fn has_capacity(&self) -> bool
Returns true when the window has capacity for more chunks.
Auto Trait Implementations§
impl Freeze for OutboundTransferState
impl RefUnwindSafe for OutboundTransferState
impl Send for OutboundTransferState
impl Sync for OutboundTransferState
impl Unpin for OutboundTransferState
impl UnsafeUnpin for OutboundTransferState
impl UnwindSafe for OutboundTransferState
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
Source§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more