[][src]Struct enet::Peer

pub struct Peer<'a, T: 'a> { /* fields omitted */ }

This struct represents an endpoint in an ENet-connection.

The lifetime of these instances is not really clear from the ENet documentation. Therefore, Peers are always borrowed, and can not really be stored anywhere.

ENet allows the association of arbitrary data with each peer. The type of this associated data is chosen through T.

Methods

impl<'a, T> Peer<'a, T>[src]

pub fn address(&self) -> Address[src]

Returns the address of this Peer.

pub fn channel_count(&self) -> usize[src]

Returns the amout of channels allocated for this Peer.

pub fn data(&self) -> Option<&T>[src]

Returns a reference to the data associated with this Peer, if set.

pub fn data_mut(&mut self) -> Option<&mut T>[src]

Returns a mutable reference to the data associated with this Peer, if set.

pub fn set_data(&mut self, data: Option<T>)[src]

Sets or clears the data associated with this Peer, replacing existing data.

pub fn incoming_bandwidth(&self) -> u32[src]

Returns the downstream bandwidth of this Peer in bytes/second.

pub fn outgoing_bandwidth(&self) -> u32[src]

Returns the upstream bandwidth of this Peer in bytes/second.

pub fn mean_rtt(&self) -> Duration[src]

Returns the mean round trip time between sending a reliable packet and receiving its acknowledgement.

pub fn reset(self)[src]

Forcefully disconnects this Peer.

The foreign host represented by the peer is not notified of the disconnection and will timeout on its connection to the local host.

pub fn state(&self) -> PeerState[src]

Returns the state this Peer is in.

pub fn send_packet(
    &mut self,
    packet: Packet,
    channel_id: u8
) -> Result<(), Error>
[src]

Queues a packet to be sent.

Actual sending will happen during Host::service.

pub fn disconnect(&mut self, user_data: u32)[src]

Disconnects from this peer.

A Disconnect event will be returned by Host::service once the disconnection is complete.

pub fn disconnect_now(self, user_data: u32)[src]

Disconnects from this peer immediately.

No Disconnect event will be created. No disconnect notification for the foreign peer is guaranteed, and this Peer is immediately reset on return from this method.

pub fn disconnect_later(&mut self, user_data: u32)[src]

Disconnects from this peer after all outgoing packets have been sent.

A Disconnect event will be returned by Host::service once the disconnection is complete.

pub fn receive<'b>(&'b mut self) -> Option<PeerPacket<'b, 'a, T>>[src]

Attempts to dequeue an incoming packet from this Peer.

On success, returns the packet and the channel id of the receiving channel.

Trait Implementations

impl<'a, T: Clone + 'a> Clone for Peer<'a, T>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<'a, T: Debug + 'a> Debug for Peer<'a, T>[src]

Auto Trait Implementations

impl<'a, T> !Send for Peer<'a, T>

impl<'a, T> !Sync for Peer<'a, T>

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.