Struct Frame

Source
pub struct Frame {
    pub flags: u8,
    pub size: u16,
    pub reliable_index: Option<u32>,
    pub sequence_index: Option<u32>,
    pub order_index: Option<u32>,
    pub order_channel: Option<u8>,
    pub fragment_meta: Option<FragmentMeta>,
    pub reliability: Reliability,
    pub body: Vec<u8>,
}
Expand description

An individual data frame, these are constructed from a payload.

Fields§

§flags: u8

The flags for this frame, the first 3 bits are reserved for the reliability while the 4th bit is used to represent if this is a fragment.

§size: u16

The length of the body of the frame. This is sized to 24 bits internally, so any number here must be within that range.

§reliable_index: Option<u32>

The Reliable index of the frame (if reliable)

§sequence_index: Option<u32>

The sequenced index of the frame (if sequenced) This is used to determine the position in frame list.

§order_index: Option<u32>

The order index of the frame (if ordered) This is used to determine the position in frame list, This is different from the sequence index in that it is used more to sequence packets in a specific manner.

§order_channel: Option<u8>

The order channel of the frame (if ordered) This is used to store order information for the frame.

§fragment_meta: Option<FragmentMeta>

The information for fragmentation (if the frame is split into parts) This is used to determine how to reassemble the frame.

§reliability: Reliability

The reliability of this frame, this is essentially used to save frames and send them back if they are lost. Otherwise, the frame is sent unreliably.

§body: Vec<u8>

The body of the frame, this is the payload of the frame.

Implementations§

Source§

impl Frame

Source

pub fn init() -> Self

Initializes a new empty frame that is Unreliable. This is usually used to inject data into.

Source

pub fn new(reliability: Reliability, body: Option<&[u8]>) -> Self

Initializes a new frame with the given reliability.

Source

pub fn is_fragmented(&self) -> bool

Whether or not the frame is fragmented.

Source

pub fn is_sequenced(&self) -> bool

Whether or not the frame is sequenced and reliable.

Source

pub fn with_meta(self, meta: FragmentMeta) -> Self

Trait Implementations§

Source§

impl Clone for Frame

Source§

fn clone(&self) -> Frame

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 Frame

Source§

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

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

impl Reader<Frame> for Frame

Source§

fn read(buf: &mut ByteReader) -> Result<Frame, Error>

Reads Self from a ByteReader. Read more
Source§

fn read_from_slice(buf: &[u8]) -> Result<Output, Error>

Reads Self from a &[u8]. Read more
Source§

impl Writer for Frame

Source§

fn write(&self, buf: &mut ByteWriter) -> Result<(), Error>

Writes Self to a ByteWriter. Read more
Source§

fn write_to_bytes(&self) -> Result<ByteWriter, Error>

This is a utility function to write Self to a ByteWriter without needing to create a ByteWriter first.

Auto Trait Implementations§

§

impl Freeze for Frame

§

impl RefUnwindSafe for Frame

§

impl Send for Frame

§

impl Sync for Frame

§

impl Unpin for Frame

§

impl UnwindSafe for Frame

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more