pub enum Transport {
    Tcp,
    FramedTcp,
    Udp,
    Ws,
}
Expand description

Enum to identified the underlying transport used. It can be passed to NetworkController::connect() and NetworkController::listen() methods to specify the transport used.

Variants§

§

Tcp

TCP protocol (available through the tcp feature). As stream protocol, receiving a message from TCP do not imply to read the entire message. If you want a packet based way to send over TCP, use FramedTcp instead.

§

FramedTcp

Tcp framed protocol (available through the tcp feature). Like TCP, but encoded with a slim frame layer to manage the data as a packet, instead of as a stream. It prefixes the message using variable integer encoding with the size of the message. Most of the time you would want to use this instead of the raw Tcp.

§

Udp

UDP protocol (available through the udp feature). Take into account that UDP is not connection oriented and a packet can be lost or received disordered. If it is specified in the listener and the address is a Ipv4 in the range of multicast ips (from 224.0.0.0 to 239.255.255.255), the listener will be configured in multicast mode.

§

Ws

WebSocket protocol (available through the websocket feature). If you use a crate::network::RemoteAddr::Str in the connect() method, you can specify an URL with wss of ws schemas to connect with or without security. If you use a crate::network::RemoteAddr::Socket the socket will be a normal websocket with the following uri: ws://{SocketAddr}/message-io-default.

Implementations§

source§

impl Transport

source

pub fn mount_adapter(self, loader: &mut DriverLoader)

Associates an adapter. This method mounts the adapters to be used in the network instance.

source

pub const fn max_message_size(self) -> usize

Maximum theorical packet payload length available for each transport.

The value returned by this function is the theorical maximum and could not be valid for all networks. You can ensure your message not exceeds udp::MAX_INTERNET_PAYLOAD_LEN in order to be more cross-platform compatible.

source

pub const fn is_connection_oriented(self) -> bool

Tell if the transport protocol is a connection oriented protocol. If it is, Connection and Disconnection events will be generated.

source

pub const fn is_packet_based(self) -> bool

Tell if the transport protocol is a packet-based protocol. It implies that any send call corresponds to a data message event. It satisfies that the number of bytes sent are the same as received. The opossite of a packet-based is a stream-based transport (e.g Tcp). In this case, reading a data message event do not imply reading the entire message sent. It is in change of the user to determinate how to read the data.

source

pub const fn id(self) -> u8

Returns the adapter id used for this transport. It is equivalent to the position of the enum starting by 0

Trait Implementations§

source§

impl Clone for Transport

source§

fn clone(&self) -> Transport

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Transport

source§

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

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

impl<'de> Deserialize<'de> for Transport

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Transport

source§

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

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

impl From<Transport> for TransportConnect

source§

fn from(transport: Transport) -> Self

Converts to this type from the input type.
source§

impl From<Transport> for TransportListen

source§

fn from(transport: Transport) -> Self

Converts to this type from the input type.
source§

impl From<u8> for Transport

source§

fn from(id: u8) -> Self

Converts to this type from the input type.
source§

impl Hash for Transport

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl IntoEnumIterator for Transport

§

type Iterator = TransportIter

source§

fn iter() -> TransportIter

source§

impl PartialEq for Transport

source§

fn eq(&self, other: &Transport) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Transport

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Copy for Transport

source§

impl Eq for Transport

source§

impl StructuralPartialEq for Transport

Auto Trait Implementations§

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
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

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,