Enum tuic::Header

source ·
#[non_exhaustive]
pub enum Header { Authenticate(Authenticate), Connect(Connect), Packet(Packet), Dissociate(Dissociate), Heartbeat(Heartbeat), }
Expand description

The command header for negotiating tasks

+-----+------+----------+
| VER | TYPE |   OPT    |
+-----+------+----------+
|  1  |  1   | Variable |
+-----+------+----------+

where:

  • VER - the TUIC protocol version
  • TYPE - command type
  • OPT - command type specific data

Command Types

There are five types of command:

  • 0x00 - Authenticate - for authenticating the multiplexed stream
  • 0x01 - Connect - for establishing a TCP relay
  • 0x02 - Packet - for relaying (fragmented part of) a UDP packet
  • 0x03 - Dissociate - for terminating a UDP relaying session
  • 0x04 - Heartbeat - for keeping the QUIC connection alive

Command Connect and Packet carry payload (stream / packet fragment)

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Authenticate(Authenticate)

§

Connect(Connect)

§

Packet(Packet)

§

Dissociate(Dissociate)

§

Heartbeat(Heartbeat)

Implementations§

source§

impl Header

source

pub const TYPE_CODE_AUTHENTICATE: u8 = 0u8

source

pub const TYPE_CODE_CONNECT: u8 = 1u8

source

pub const TYPE_CODE_PACKET: u8 = 2u8

source

pub const TYPE_CODE_DISSOCIATE: u8 = 3u8

source

pub const TYPE_CODE_HEARTBEAT: u8 = 4u8

source

pub const fn type_code(&self) -> u8

Returns the command type code

source

pub fn len(&self) -> usize

Returns the serialized length of the command

source§

impl Header

source

pub async fn async_marshal( &self, s: &mut impl AsyncWrite + Unpin ) -> Result<(), IoError>

Marshals the header into an AsyncWrite stream

source

pub fn marshal(&self, s: &mut impl Write) -> Result<(), IoError>

Marshals the header into a Write stream

source

pub fn write(&self, buf: &mut impl BufMut)

Writes the header into a BufMut

source§

impl Header

source

pub async fn async_unmarshal( s: &mut impl AsyncRead + Unpin ) -> Result<Self, UnmarshalError>

Unmarshals a header from an AsyncRead stream

source

pub fn unmarshal(s: &mut impl Read) -> Result<Self, UnmarshalError>

Unmarshals a header from a Read stream

Trait Implementations§

source§

impl Clone for Header

source§

fn clone(&self) -> Header

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 Header

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.