Packet

Struct Packet 

Source
pub struct Packet { /* private fields */ }
Expand description

User-friendly packet containing payload, endpoint, and guarantees.

Implementations§

Source§

impl Packet

Source

pub fn new( addr: SocketAddr, payload: Arc<[u8]>, delivery: DeliveryGuarantee, ordering: OrderingGuarantee, channel_id: u8, ) -> Packet

Creates a new packet with the specified guarantees and channel.

Source

pub fn unreliable(addr: SocketAddr, payload: Vec<u8>) -> Packet

Creates an unreliable, unordered packet on channel 0 (fire-and-forget).

Source

pub fn unreliable_sequenced( addr: SocketAddr, payload: Vec<u8>, stream_id: Option<u8>, ) -> Packet

Creates an unreliable, sequenced packet on channel 0 (drops out-of-order).

Source

pub fn unsequenced(addr: SocketAddr, payload: Vec<u8>) -> Packet

Creates an unreliable, unsequenced packet on channel 0 (prevents duplicates, allows out-of-order).

Source

pub fn reliable_unordered(addr: SocketAddr, payload: Vec<u8>) -> Packet

Creates a reliable, unordered packet on channel 0 (guaranteed delivery).

Source

pub fn reliable_ordered( addr: SocketAddr, payload: Vec<u8>, stream_id: Option<u8>, ) -> Packet

Creates a reliable, ordered packet on channel 0 (TCP-like).

Source

pub fn reliable_sequenced( addr: SocketAddr, payload: Vec<u8>, stream_id: Option<u8>, ) -> Packet

Creates a reliable, sequenced packet on channel 0 (keeps latest).

Source

pub fn unreliable_on_channel( addr: SocketAddr, payload: Vec<u8>, channel_id: u8, ) -> Packet

Creates an unreliable, unordered packet on specified channel (fire-and-forget).

Source

pub fn reliable_on_channel( addr: SocketAddr, payload: Vec<u8>, channel_id: u8, ) -> Packet

Creates a reliable, unordered packet on specified channel (guaranteed delivery).

Source

pub fn payload(&self) -> &[u8]

Returns a slice of the packet payload.

Source

pub fn into_payload(self) -> Arc<[u8]>

Consumes the packet and returns the payload.

Source

pub fn payload_arc(&self) -> Arc<[u8]>

Returns a clone of the underlying Arc payload for zero-copy sharing.

Source

pub fn addr(&self) -> SocketAddr

Returns the remote endpoint address.

Source

pub fn delivery_guarantee(&self) -> DeliveryGuarantee

Returns the delivery guarantee for this packet.

Source

pub fn order_guarantee(&self) -> OrderingGuarantee

Returns the ordering guarantee for this packet.

Source

pub fn channel_id(&self) -> u8

Returns the channel ID for this packet.

Trait Implementations§

Source§

impl Clone for Packet

Source§

fn clone(&self) -> Packet

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 Packet

Source§

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

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

impl PartialEq for Packet

Source§

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

Source§

impl StructuralPartialEq for Packet

Auto Trait Implementations§

§

impl Freeze for Packet

§

impl RefUnwindSafe for Packet

§

impl Send for Packet

§

impl Sync for Packet

§

impl Unpin for Packet

§

impl UnwindSafe for Packet

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