Skip to main content

SenderMachine

Struct SenderMachine 

Source
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 bytes
  • MTU - Maximum transmission unit (packet size)

Implementations§

Source§

impl<const WIN: usize, const BUF: usize, const MTU: usize> SenderMachine<WIN, BUF, MTU>

Source

pub fn new(config: SenderConfig) -> Self

Create a new sender state machine with the given configuration.

Source

pub fn config(&self) -> &SenderConfig

Returns a reference to the sender configuration.

Source

pub fn max_payload_per_packet(&self) -> usize

Maximum payload bytes per packet given the MTU and header overhead.

Source

pub fn available_bytes(&self) -> usize

Available space in the send buffer (bytes).

Source

pub fn available_window(&self) -> usize

Available slots in send window.

Source

pub fn unacked_count(&self) -> usize

Number of unacked packets.

Source

pub fn is_idle(&self) -> bool

Check if all data has been acknowledged.

Source

pub fn get_payload(&self, seq: SequenceCount) -> Option<PayloadInfo<'_>>

Retrieve payload info for a buffered packet by sequence number.

Source

pub fn handle( &mut self, event: SenderEvent<'_>, actions: &mut SenderActions, ) -> Result<(), SenderError>

Process an event and produce actions.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.