pub struct Peer { /* private fields */ }Expand description
An object representing a connection to a remote host.
Connection States
Implementations
sourceimpl Peer
impl Peer
sourcepub fn send(&mut self, data: Box<[u8]>, channel_id: usize, mode: SendMode)
pub fn send(&mut self, data: Box<[u8]>, channel_id: usize, mode: SendMode)
Enqueues a packet for delivery to the remote host. The packet will be sent on the given channel according to the specified mode.
Panics
This function will panic if channel_id does not refer to a valid channel, or if
data.len() exceeds the maximum packet
size.
sourcepub fn poll_events(&mut self) -> impl Iterator<Item = Event>
pub fn poll_events(&mut self) -> impl Iterator<Item = Event>
Delivers all available events for this connection. See Event for a list of
possible event types.
Note 1: All events are considered delivered even if the iterator is not consumed until the end.
Note 2: Packets that have been received will not be acknowledged until this function is called. The number of packets that may be queued prior to being delivered is limited by a maximum transfer window, and by the maximum receive allocation.
sourcepub fn disconnect(&self)
pub fn disconnect(&self)
Terminates the connection, notifying the remote host. If currently connected, all pending packets will be sent prior to disconnecting.
A Disconnect event will be generated if a connection was previously
established.
sourcepub fn disconnect_now(&self)
pub fn disconnect_now(&self)
Immediately terminates the connection, without notifying the remote host.
A Disconnect event will be generated if a connection was previously
established.
sourcepub fn address(&self) -> SocketAddr
pub fn address(&self) -> SocketAddr
Returns the address of the remote host.
sourcepub fn rtt_s(&self) -> Option<f64>
pub fn rtt_s(&self) -> Option<f64>
Returns the current round-trip time estimate (RTT), in seconds.
If an RTT estimate has not yet been computed, None is returned instead.
sourcepub fn is_disconnected(&self) -> bool
pub fn is_disconnected(&self) -> bool
Returns true if the connection has been terminated or timed out.
Auto Trait Implementations
impl !RefUnwindSafe for Peer
impl !Send for Peer
impl !Sync for Peer
impl Unpin for Peer
impl !UnwindSafe for Peer
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more