pub struct ReliableUdp {
pub peer_addr: SocketAddr,
/* private fields */
}Expand description
Reliable ordered UDP transport for a single peer connection.
Caller owns the NonBlockingSocket and passes it in for send operations.
tick() must be called frequently (each game frame) to drive retransmits.
Fields§
§peer_addr: SocketAddrImplementations§
Source§impl ReliableUdp
impl ReliableUdp
pub fn new(peer_addr: SocketAddr) -> Self
pub fn state(&self) -> ConnectionState
pub fn stats(&self) -> &TransportStats
pub fn rtt_ms(&self) -> f64
Sourcepub fn send_reliable(&mut self, socket: &NonBlockingSocket, packet: Packet)
pub fn send_reliable(&mut self, socket: &NonBlockingSocket, packet: Packet)
Enqueue a reliable packet for delivery.
Sourcepub fn send_unreliable(&mut self, socket: &NonBlockingSocket, packet: Packet)
pub fn send_unreliable(&mut self, socket: &NonBlockingSocket, packet: Packet)
Send a best-effort (unreliable) packet.
Sourcepub fn receive(&mut self, raw: &[u8]) -> Vec<Packet>
pub fn receive(&mut self, raw: &[u8]) -> Vec<Packet>
Called by ConnectionManager when a raw datagram arrives from this peer.
Returns decoded in-order packets ready for the application.
Sourcepub fn tick(&mut self, socket: &NonBlockingSocket)
pub fn tick(&mut self, socket: &NonBlockingSocket)
Drive retransmits, keepalives, and timeout detection.
Call every frame. Returns packets that need to be sent via socket.
pub fn disconnect(&mut self, socket: &NonBlockingSocket)
pub fn reset_reorder(&mut self)
Auto Trait Implementations§
impl Freeze for ReliableUdp
impl RefUnwindSafe for ReliableUdp
impl Send for ReliableUdp
impl Sync for ReliableUdp
impl Unpin for ReliableUdp
impl UnsafeUnpin for ReliableUdp
impl UnwindSafe for ReliableUdp
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.