Enum message_io::network::NetEvent[][src]

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

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

Variants

Connected(Endpointbool)

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.

Tuple Fields of Connected

0: Endpoint1: bool
Accepted(EndpointResourceId)

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.

Tuple Fields of Accepted

0: Endpoint1: ResourceId
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.

Tuple Fields of Message

0: Endpoint1: &'a [u8]
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.

Tuple Fields of Disconnected

0: Endpoint

Trait Implementations

Formats the value using the given formatter. Read more

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.