pub struct ReliableTransport { /* private fields */ }Expand description
Reliable transport layer
Implementations§
Source§impl ReliableTransport
impl ReliableTransport
Sourcepub fn new(config: ReliableConfig) -> Self
pub fn new(config: ReliableConfig) -> Self
Create a new reliable transport
Sourcepub fn send(&mut self, data: Bytes) -> Result<(u32, Bytes)>
pub fn send(&mut self, data: Bytes) -> Result<(u32, Bytes)>
Queue a packet for sending
Returns the packet ID and the data to send
Sourcepub fn receive(&mut self, packet_id: u32, data: Bytes) -> Result<Option<Bytes>>
pub fn receive(&mut self, packet_id: u32, data: Bytes) -> Result<Option<Bytes>>
Process received packet
Returns the payload if this is the next expected packet, otherwise buffers it for later delivery.
Sourcepub fn process_acks(&mut self, acks: &[u32])
pub fn process_acks(&mut self, acks: &[u32])
Process received ACKs
Sourcepub fn should_send_ack(&self) -> bool
pub fn should_send_ack(&self) -> bool
Check if we should send a standalone ACK
Sourcepub fn get_retransmits(&mut self) -> Vec<(u32, Bytes)>
pub fn get_retransmits(&mut self) -> Vec<(u32, Bytes)>
Get packets that need retransmission
Sourcepub fn has_pending(&self) -> bool
pub fn has_pending(&self) -> bool
Check if there are pending packets
Sourcepub fn next_timeout(&self) -> Option<Duration>
pub fn next_timeout(&self) -> Option<Duration>
Get next timeout (when we need to check for retransmits)
Auto Trait Implementations§
impl Freeze for ReliableTransport
impl RefUnwindSafe for ReliableTransport
impl Send for ReliableTransport
impl Sync for ReliableTransport
impl Unpin for ReliableTransport
impl UnwindSafe for ReliableTransport
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