ProtocolCommand

Enum ProtocolCommand 

Source
pub enum ProtocolCommand {
Show 16 variants SendReliable { channel_id: u8, sequence: u16, ordered: bool, data: SharedBytes, }, SendUnreliable { channel_id: u8, data: SharedBytes, }, SendUnreliableSequenced { channel_id: u8, sequence: u16, data: SharedBytes, }, SendUnsequenced { channel_id: u8, unsequenced_group: u16, data: SharedBytes, }, SendFragment { channel_id: u8, sequence: u16, ordered: bool, fragment_id: u8, fragment_count: u8, data: SharedBytes, }, SendUnreliableFragment { channel_id: u8, sequence: u16, fragment_id: u8, fragment_count: u8, data: SharedBytes, }, Acknowledge { sequence: u16, received_mask: u32, sent_time: Option<u32>, }, Ping { timestamp: u32, }, Pong { timestamp: u32, }, Connect { channels: u8, mtu: u16, protocol_version: u16, outgoing_session_id: u16, connect_id: u32, }, VerifyConnect { peer_id: u16, channels: u8, mtu: u16, incoming_session_id: u16, outgoing_session_id: u16, window_size: u32, }, Disconnect { reason: u32, }, BandwidthLimit { incoming: u32, outgoing: u32, }, ThrottleConfigure { interval: u32, acceleration: u32, deceleration: u32, }, PMTUProbe { size: u16, token: u32, payload: SharedBytes, }, PMTUReply { size: u16, token: u32, },
}
Expand description

Protocol commands that can be sent between peers.

All protocol operations are represented as discrete commands that can be aggregated.

Variants§

§

SendReliable

Send reliable data on a channel

Fields

§channel_id: u8

Channel identifier (0-255)

§sequence: u16

Sequence number for ordering

§ordered: bool

Whether to deliver in order on receive (true) or unordered (false)

§data: SharedBytes

Payload data (shared, sliceable)

§

SendUnreliable

Send unreliable data on a channel

Fields

§channel_id: u8

Channel identifier (0-255)

§data: SharedBytes

Payload data (shared slice)

§

SendUnreliableSequenced

Send sequenced unreliable data (drops old packets)

Fields

§channel_id: u8

Channel identifier (0-255)

§sequence: u16

Sequence number for dropping old packets

§data: SharedBytes

Payload data (shared slice)

§

SendUnsequenced

Send unsequenced unreliable data (prevents duplicates without ordering)

Fields

§channel_id: u8

Channel identifier (0-255)

§unsequenced_group: u16

Unsequenced group identifier for duplicate detection

§data: SharedBytes

Payload data (shared slice)

§

SendFragment

Fragment of a larger reliable packet

Fields

§channel_id: u8

Channel identifier (0-255)

§sequence: u16

Sequence number of the original packet

§ordered: bool

Whether to deliver in order on receive (true) or unordered (false)

§fragment_id: u8

Fragment index (0-based)

§fragment_count: u8

Total number of fragments

§data: SharedBytes

Fragment data (shared slice)

§

SendUnreliableFragment

Fragment of a larger unreliable packet

Fields

§channel_id: u8

Channel identifier (0-255)

§sequence: u16

Sequence number of the original packet (for reassembly)

§fragment_id: u8

Fragment index (0-based)

§fragment_count: u8

Total number of fragments

§data: SharedBytes

Fragment data (shared slice)

§

Acknowledge

Acknowledge received reliable packets

Fields

§sequence: u16

Sequence number being acknowledged

§received_mask: u32

Bitfield of additional acknowledged packets (32 packets before sequence)

§sent_time: Option<u32>

Timestamp for RTT calculation (optional)

§

Ping

Ping to measure RTT and keep connection alive

Fields

§timestamp: u32

Timestamp (milliseconds since epoch or relative)

§

Pong

Pong response to ping

Fields

§timestamp: u32

Original timestamp from ping

§

Connect

Request to establish connection (3-way handshake step 1)

Fields

§channels: u8

Number of channels to allocate

§mtu: u16

Maximum transmission unit

§protocol_version: u16

Protocol version

§outgoing_session_id: u16

Outgoing session ID from client

§connect_id: u32

Connect ID for replay protection

§

VerifyConnect

Verify connection (3-way handshake step 2) - replaces old ConnectAck

Fields

§peer_id: u16

Assigned peer ID

§channels: u8

Channels allocated

§mtu: u16

Maximum transmission unit

§incoming_session_id: u16

Incoming session ID (from server’s perspective)

§outgoing_session_id: u16

Outgoing session ID (from server’s perspective)

§window_size: u32

Window size for flow control

§

Disconnect

Request to disconnect

Fields

§reason: u32

Reason code (application-defined)

§

BandwidthLimit

Bandwidth limit notification

Fields

§incoming: u32

Incoming bandwidth limit (bytes/sec, 0 = unlimited)

§outgoing: u32

Outgoing bandwidth limit (bytes/sec, 0 = unlimited)

§

ThrottleConfigure

Throttle configuration for congestion control

Fields

§interval: u32

Throttle interval in milliseconds

§acceleration: u32

Throttle acceleration rate

§deceleration: u32

Throttle deceleration rate

§

PMTUProbe

Path MTU probe: request to test a payload of given size

Fields

§size: u16

Probe payload size in bytes

§token: u32

Correlation token

§payload: SharedBytes

Probe payload (shared slice) sized to size

§

PMTUReply

Path MTU reply: response to a PMTU probe

Fields

§size: u16

Echoed probe size

§token: u32

Echoed token

Implementations§

Source§

impl ProtocolCommand

Source

pub fn command_type(&self) -> u8

Returns the command type identifier for serialization

Source

pub fn is_reliable(&self) -> bool

Returns true if this command requires reliable delivery

Source

pub fn channel_id(&self) -> Option<u8>

Returns the channel ID if this is a data command

Trait Implementations§

Source§

impl Clone for ProtocolCommand

Source§

fn clone(&self) -> ProtocolCommand

Returns a duplicate 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 ProtocolCommand

Source§

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

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

impl PartialEq for ProtocolCommand

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ProtocolCommand

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

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

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

Source§

fn vzip(self) -> V