ConnectorParam

Trait ConnectorParam 

Source
pub trait ConnectorParam {
    type TSend: for<'a> Deserialize<'a> + Serialize + Debug + Eq + PartialEq;
    type TReceive: for<'a> Deserialize<'a> + Serialize + Debug + Eq + PartialEq;

    const PING_INTERVAL_S: f64 = 0.5f64;
    const REQUEST_MISSING_PACKET_INTERVAL_S: f64 = 1f64;
    const EMIT_UNCONFIRMED_PACKET_INTERVAL_S: f64 = 1f64;
    const RECEIVE_PING_TIMEOUT_S: f64 = _;
    const SEND_PING_TIMEOUT_S: f64 = _;
}
Expand description

Settings that are set up for a Connector. This can be used to tweak your Connector at compile-time

Provided Associated Constants§

Source

const PING_INTERVAL_S: f64 = 0.5f64

The interval at which pings are being emitted to the other connector. This should be set in relation to RECEIVE_PING_TIMEOUT_S and SEND_PING_TIMEOUT_S, and how often you expect to lose packets.

Source

const REQUEST_MISSING_PACKET_INTERVAL_S: f64 = 1f64

The interval at which missing packets are being requested from the connector

Source

const EMIT_UNCONFIRMED_PACKET_INTERVAL_S: f64 = 1f64

The interval at which unconfirmed packets are being send to the other connector

Source

const RECEIVE_PING_TIMEOUT_S: f64 = _

The time that it takes before this connector assumes it has lost connection to the other connector

Source

const SEND_PING_TIMEOUT_S: f64 = _

The time that it takes before this connector assumes it has lost connection to the other connector

Required Associated Types§

Source

type TSend: for<'a> Deserialize<'a> + Serialize + Debug + Eq + PartialEq

The type that this connector will be sending. This is usually an enum.


// For the server:
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)]
pub enum ServerToClient {
    LoginResult { success: bool },
}

struct ConnectorConfig;


impl ConnectorParam for ConnectorConfig {
    type TSend = ServerToClient;
    // Other fields omitted
}
Source

type TReceive: for<'a> Deserialize<'a> + Serialize + Debug + Eq + PartialEq

The type that this connector will be sending. This is usually an enum.



// For the server:
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq)]
pub enum ClientToServer {
    Login { params: AuthenticateParams },
}

struct ConnectorConfig;

impl ConnectorParam for ConnectorConfig {
    type TReceive = ClientToServer;
    // Other fields omitted
}

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§