Struct HeaderEncoder

Source
pub struct HeaderEncoder<Stage = Magic> { /* private fields */ }
Expand description

Encoder for a PROXY Protocol v2 header.

Implementations§

Source§

impl HeaderEncoder<Magic>

Source

pub fn encode(header: &Header) -> Encoded

Encodes a PROXY Protocol v2 header from the given Header.

This returns a Encoded which can be finalized to produce the encoded header bytes. To write some extensions to the header, use the methods like Encoded::write_ext_alpn, etc.

Source§

impl HeaderEncoder<Finished>

Source

pub fn write_ext_alpn(self, alpn: &[u8]) -> Result<Self, EncodeError>

Writes the ALPN extension bytes to the header.

See ExtensionType::ALPN.

Source

pub fn write_ext_authority(self, authority: &[u8]) -> Result<Self, EncodeError>

Writes the Authority extension bytes to the header.

See ExtensionType::Authority.

Source

pub fn write_ext_no_op(self, padding: u16) -> Result<Self, EncodeError>

Writes padding zeros to the header, the total size is 3 + padding.

See ExtensionType::NoOp.

Source

pub fn write_ext_unique_id(self, payload: &[u8]) -> Result<Self, EncodeError>

Writes the UniqueId extension bytes to the header.

See ExtensionType::UniqueId.

Source

pub fn write_ext_network_namespace( self, payload: &[u8], ) -> Result<Self, EncodeError>

Writes the NetworkNamespace extension bytes to the header.

See ExtensionType::NetworkNamespace.

Source

pub fn write_ext_custom(self, extension: ExtensionRef<'_>) -> Self

Writes a custom extension to the header.

Notice: will not check if the typ is valid.

Source

pub fn finish_with_crc32c(self) -> Result<Vec<u8>, EncodeError>

Calculates and writes the CRC32C extension bytes to the header and finalizes the header encoding.

Source

pub fn finish(self) -> Result<Vec<u8>, EncodeError>

Finalizes the header encoding.

Trait Implementations§

Source§

impl<Stage: Debug> Debug for HeaderEncoder<Stage>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Stage> Freeze for HeaderEncoder<Stage>

§

impl<Stage> RefUnwindSafe for HeaderEncoder<Stage>
where Stage: RefUnwindSafe,

§

impl<Stage> Send for HeaderEncoder<Stage>
where Stage: Send,

§

impl<Stage> Sync for HeaderEncoder<Stage>
where Stage: Sync,

§

impl<Stage> Unpin for HeaderEncoder<Stage>
where Stage: Unpin,

§

impl<Stage> UnwindSafe for HeaderEncoder<Stage>
where Stage: UnwindSafe,

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