Enum Packet

Source
pub enum Packet<'a> {
    ConnectionRequest {
        version_info: [u8; 13],
        protocol_id: u64,
        expire_timestamp: u64,
        xnonce: [u8; 24],
        data: [u8; 1024],
    },
    ConnectionDenied,
    Challenge {
        token_sequence: u64,
        token_data: [u8; 300],
    },
    Response {
        token_sequence: u64,
        token_data: [u8; 300],
    },
    KeepAlive {
        client_index: u32,
        max_clients: u32,
    },
    Payload(&'a [u8]),
    Disconnect,
}

Variants§

§

ConnectionRequest

Fields

§version_info: [u8; 13]
§protocol_id: u64
§expire_timestamp: u64
§xnonce: [u8; 24]
§data: [u8; 1024]
§

ConnectionDenied

§

Challenge

Fields

§token_sequence: u64
§token_data: [u8; 300]
§

Response

Fields

§token_sequence: u64
§token_data: [u8; 300]
§

KeepAlive

Fields

§client_index: u32
§max_clients: u32
§

Payload(&'a [u8])

§

Disconnect

Implementations§

Source§

impl<'a> Packet<'a>

Source

pub fn packet_type(&self) -> PacketType

Source

pub fn id(&self) -> u8

Source

pub fn connection_request_from_token(connect_token: &ConnectToken) -> Self

Source

pub fn generate_challenge( client_id: u64, user_data: &[u8; 256], challenge_sequence: u64, challenge_key: &[u8; 32], ) -> Result<Self, NetcodeError>

Source

pub fn encode( &self, buffer: &mut [u8], protocol_id: u64, crypto_info: Option<(u64, &[u8; 32])>, encrypted: bool, ) -> Result<usize, NetcodeError>

Source

pub fn decode( buffer: &'a mut [u8], protocol_id: u64, private_key: Option<&[u8; 32]>, replay_protection: Option<&mut ReplayProtection>, encrypted: bool, ) -> Result<(u64, Self), NetcodeError>

Source

pub fn packet_type_from_buffer( buffer: &[u8], ) -> Result<PacketType, NetcodeError>

Gets the packet type of a packet.

Trait Implementations§

Source§

impl<'a> Debug for Packet<'a>

Source§

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

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

impl<'a> PartialEq for Packet<'a>

Source§

fn eq(&self, other: &Packet<'a>) -> 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<'a> Eq for Packet<'a>

Source§

impl<'a> StructuralPartialEq for Packet<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Packet<'a>

§

impl<'a> RefUnwindSafe for Packet<'a>

§

impl<'a> Send for Packet<'a>

§

impl<'a> Sync for Packet<'a>

§

impl<'a> Unpin for Packet<'a>

§

impl<'a> UnwindSafe for Packet<'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

Source§

type Output = T

Should always be Self
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.