PP2TlvRestore

Trait PP2TlvRestore 

Source
pub trait PP2TlvRestore: Debug + Display {
    // Required methods
    fn is_in_range(tlv_type: u8, tlv_parent_type: Option<u8>) -> bool;
    fn restore(tlv_type: u8, cur: &mut Cursor<&[u8]>) -> HaProxRes<Self>
       where Self: Sized;
    fn contains_subtype(&self) -> bool;
}
Expand description

A trait which provides functionality for protocol_parser. A user’s program can implement this on the own set of TLV in order to parse the received data and return the result.

Required Methods§

Source

fn is_in_range(tlv_type: u8, tlv_parent_type: Option<u8>) -> bool

Checks if the current TLV is in range of the tlv_parent_type parent. If tlv_parent_type is None then the tlv_type can be checked against the main range. The tlv_parent_type is set when the current tlv_type is a subset of the parent.

It is called by the TLV iterator to determine which parser should be called next or if it is out of range then error.

§Arguments
  • tlv_type - a current tlv ID.

  • tlv_parent_type - a parent TLV ID if any.

§Returns

Either true or false. If not in range then false.

Source

fn restore(tlv_type: u8, cur: &mut Cursor<&[u8]>) -> HaProxRes<Self>
where Self: Sized,

A function which is called when the parsing reaches the TLV’s payload. The cursor is poiniting to the beginning of the payload and the inner buffer is a slice from the main buffer of size of the TLV’s payload.

§Arguments
  • tlv_type - a current TLV type.

  • cur - a cursor pointing to the beginning of the TLV’s payload.

§Returns

A HaProxRes should be returned with

Source

fn contains_subtype(&self) -> bool

Should return true if the current instance contains subtypes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl PP2TlvRestore for PP2Tlvs

Implementation of the PP2TlvRestore for the build-in protocol PP2Tlvs items.

Source§

impl PP2TlvRestore for ProxyV2Dummy