pub enum NetEvent<'a> {
    Connected(Endpoint, bool),
    Accepted(Endpoint, ResourceId),
    Message(Endpoint, &'a [u8]),
    Disconnected(Endpoint),
}
Expand description

Enum used to describe a network event that an internal transport adapter has produced.

Variants§

§

Connected(Endpoint, bool)

Connection result. This event is only generated after a crate::network::NetworkController::connect() call. The event contains the endpoint of the connection (same endpoint returned by the connect() method), and a boolean indicating the result of that connection. In non connection-oriented transports as UDP it simply means that the resource is ready to use, and the boolean will be always true. In connection-oriented transports it means that the handshake has been performed, and the connection is established and ready to use. Since this handshake could fail, the boolean could be false.

§

Accepted(Endpoint, ResourceId)

New endpoint has been accepted by a listener and considered ready to use. The event contains the resource id of the listener that accepted this connection.

Note that this event will only be generated by connection-oriented transports as TCP.

§

Message(Endpoint, &'a [u8])

Input message received by the network. In packet-based transports, the data of a message sent corresponds with the data of this event. This one-to-one relation is not conserved in stream-based transports as TCP.

If you want a packet-based protocol over TCP use crate::network::Transport::FramedTcp.

§

Disconnected(Endpoint)

This event is only dispatched when a connection is lost. Remove explicitely a resource will NOT generate the event. When this event is received, the resource is considered already removed, the user do not need to remove it after this event. A NetEvent::Message event will never be generated after this event from this endpoint. Note that this event will only be generated by connection-oriented transports as TCP. UDP, for example, is NOT connection-oriented, and the event can no be detected.

Trait Implementations§

source§

impl Debug for NetEvent<'_>

source§

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

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

impl From<NetEvent<'_>> for StoredNetEvent

source§

fn from(net_event: NetEvent<'_>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for NetEvent<'a>

§

impl<'a> Send for NetEvent<'a>

§

impl<'a> Sync for NetEvent<'a>

§

impl<'a> Unpin for NetEvent<'a>

§

impl<'a> UnwindSafe for NetEvent<'a>

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

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V