Skip to main content

SrsppReceiver

Struct SrsppReceiver 

Source
pub struct SrsppReceiver<L: NetworkWrite + NetworkRead<Error = <L as NetworkWrite>::Error>, R: ReceiverBackend, const MTU: usize> { /* private fields */ }
Expand description

Async srspp receiver.

Receives messages reliably over the link, handling reordering and reassembly. Sends ACKs to the remote sender.

Implementations§

Source§

impl<L: NetworkWrite + NetworkRead<Error = <L as NetworkWrite>::Error>, R: ReceiverBackend, const MTU: usize> SrsppReceiver<L, R, MTU>

Source

pub fn new( config: ReceiverConfig, remote_address: Address, link: L, ticks_per_sec: u32, ) -> Self

Create a new receiver for a specific remote sender.

Source

pub async fn recv(&mut self, buf: &mut [u8]) -> Result<usize, SrsppError>

Receive the next complete message.

Blocks until a message is available.

Source

pub fn try_recv(&mut self, buf: &mut [u8]) -> Option<usize>

Try to receive a message without blocking.

Returns None if no complete message is available.

Source

pub async fn wait_for_message( &mut self, ) -> Result<DeliveryToken<'_, L, R, MTU>, SrsppError>

Wait for a complete message to become available.

Returns a DeliveryToken that borrows &mut self, preventing further receives while the token is held. Call DeliveryToken::consume with a synchronous closure to read the message data without an intermediate copy.

Source

pub async fn recv_with<F, Ret>(&mut self, f: F) -> Result<Ret, SrsppError>
where F: FnOnce(&[u8]) -> Ret,

Wait for a message and process it in-place with a closure.

Equivalent to wait_for_message().await?.consume(f) but more concise when you don’t need the DeliveryToken metadata.

Source

pub async fn poll(&mut self) -> Result<(), SrsppError>

Poll for incoming data and handle timers.

Auto Trait Implementations§

§

impl<L, R, const MTU: usize> Freeze for SrsppReceiver<L, R, MTU>
where L: Freeze, R: Freeze,

§

impl<L, R, const MTU: usize> RefUnwindSafe for SrsppReceiver<L, R, MTU>

§

impl<L, R, const MTU: usize> Send for SrsppReceiver<L, R, MTU>
where L: Send, R: Send,

§

impl<L, R, const MTU: usize> Sync for SrsppReceiver<L, R, MTU>
where L: Sync, R: Sync,

§

impl<L, R, const MTU: usize> Unpin for SrsppReceiver<L, R, MTU>
where L: Unpin, R: Unpin,

§

impl<L, R, const MTU: usize> UnsafeUnpin for SrsppReceiver<L, R, MTU>
where L: UnsafeUnpin, R: UnsafeUnpin,

§

impl<L, R, const MTU: usize> UnwindSafe for SrsppReceiver<L, R, MTU>
where L: UnwindSafe, R: UnwindSafe,

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.