PP2TlvRestore

Trait PP2TlvRestore 

Source
pub trait PP2TlvRestore<'zc>:
    Debug
    + Display
    + 'zc {
    type TlvTblRes;

    // Required methods
    fn is_in_range(tlv_type: u8, tlv_parent_type: Option<u8>) -> bool;
    fn contains_subtype(item: &Self::TlvTblRes) -> bool;
    fn restore(
        tlv_type: u8,
        cur: &mut Cursor<&'zc [u8]>,
    ) -> HaProxRes<Self::TlvTblRes>;
}
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 Associated Types§

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 contains_subtype(item: &Self::TlvTblRes) -> bool

Should return true if the current instance contains subtypes.

Source

fn restore( tlv_type: u8, cur: &mut Cursor<&'zc [u8]>, ) -> HaProxRes<Self::TlvTblRes>

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

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§