pub struct SenderMachine<const WIN: usize, const BUF: usize, const MTU: usize> { /* private fields */ }Expand description
Sender state machine.
Handles segmentation, buffering, and retransmission. Completely synchronous - no I/O, no async.
§Type Parameters
WIN- Maximum number of in-flight packets (window size)BUF- Total send buffer size in bytesMTU- Maximum transmission unit (packet size)
Implementations§
Source§impl<const WIN: usize, const BUF: usize, const MTU: usize> SenderMachine<WIN, BUF, MTU>
impl<const WIN: usize, const BUF: usize, const MTU: usize> SenderMachine<WIN, BUF, MTU>
Sourcepub fn new(config: SenderConfig) -> Self
pub fn new(config: SenderConfig) -> Self
Create a new sender state machine with the given configuration.
Sourcepub fn config(&self) -> &SenderConfig
pub fn config(&self) -> &SenderConfig
Returns a reference to the sender configuration.
Sourcepub fn max_payload_per_packet(&self) -> usize
pub fn max_payload_per_packet(&self) -> usize
Maximum payload bytes per packet given the MTU and header overhead.
Sourcepub fn available_bytes(&self) -> usize
pub fn available_bytes(&self) -> usize
Available space in the send buffer (bytes).
Sourcepub fn available_window(&self) -> usize
pub fn available_window(&self) -> usize
Available slots in send window.
Sourcepub fn unacked_count(&self) -> usize
pub fn unacked_count(&self) -> usize
Number of unacked packets.
Sourcepub fn get_payload(&self, seq: SequenceCount) -> Option<PayloadInfo<'_>>
pub fn get_payload(&self, seq: SequenceCount) -> Option<PayloadInfo<'_>>
Retrieve payload info for a buffered packet by sequence number.
Sourcepub fn handle(
&mut self,
event: SenderEvent<'_>,
actions: &mut SenderActions,
) -> Result<(), SenderError>
pub fn handle( &mut self, event: SenderEvent<'_>, actions: &mut SenderActions, ) -> Result<(), SenderError>
Process an event and produce actions.
Sourcepub fn mark_transmitted(&mut self, seq: SequenceCount)
pub fn mark_transmitted(&mut self, seq: SequenceCount)
Mark a packet as transmitted (awaiting ACK).
Call this after sending a packet from a Transmit action.
Auto Trait Implementations§
impl<const WIN: usize, const BUF: usize, const MTU: usize> Freeze for SenderMachine<WIN, BUF, MTU>
impl<const WIN: usize, const BUF: usize, const MTU: usize> RefUnwindSafe for SenderMachine<WIN, BUF, MTU>
impl<const WIN: usize, const BUF: usize, const MTU: usize> Send for SenderMachine<WIN, BUF, MTU>
impl<const WIN: usize, const BUF: usize, const MTU: usize> Sync for SenderMachine<WIN, BUF, MTU>
impl<const WIN: usize, const BUF: usize, const MTU: usize> Unpin for SenderMachine<WIN, BUF, MTU>
impl<const WIN: usize, const BUF: usize, const MTU: usize> UnsafeUnpin for SenderMachine<WIN, BUF, MTU>
impl<const WIN: usize, const BUF: usize, const MTU: usize> UnwindSafe for SenderMachine<WIN, BUF, MTU>
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