Peers

Struct Peers 

Source
pub struct Peers { /* private fields */ }
Expand description

Every live connection, indexed the four ways the runtime needs.

Registration and removal are explicit rather than RAII on Peer, because the voice plane holds Arc<Peer> clones across .await points: a peer must stop being findable the moment its connection ends, while the last in-flight packet is allowed to finish with the copy it already has.

Implementations§

Source§

impl Peers

Source

pub fn new() -> Peers

Source

pub fn insert(&self, peer: Arc<Peer>)

Source

pub fn remove(&self, connection: ConnectionId) -> Option<Arc<Peer>>

Forget a connection. Any address it had proven is released with it, so a later datagram from that address is re-proven rather than delivered to whoever inherits the socket.

Source

pub fn by_connection(&self, connection: ConnectionId) -> Option<Arc<Peer>>

Source

pub fn by_session(&self, session: SessionId) -> Option<Arc<Peer>>

Source

pub fn by_address(&self, address: SocketAddr) -> Option<Arc<Peer>>

Source

pub fn candidates(&self, host: IpAddr) -> Vec<Arc<Peer>>

The connections whose TCP peer shares this host address.

Source

pub fn bind(&self, address: SocketAddr, peer: &Arc<Peer>)

Bind a proven address to a peer.

The address is rebound, not merged: a client behind a NAT that reassigns its port keeps working, and the old entry is dropped so it cannot deliver to a peer that has moved.

Source

pub fn on_shard(&self, shard: ShardId) -> Vec<Arc<Peer>>

Every live connection attached to one shard.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Trait Implementations§

Source§

impl Debug for Peers

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Peers

Source§

fn default() -> Peers

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !Freeze for Peers

§

impl RefUnwindSafe for Peers

§

impl Send for Peers

§

impl Sync for Peers

§

impl Unpin for Peers

§

impl UnwindSafe for Peers

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.