Skip to main content

Decoder

Struct Decoder 

Source
pub struct Decoder { /* private fields */ }
Expand description

Stateful IPFIX decoder holding the Template cache of one Transport Session

Implementations§

Source§

impl Decoder

Source

pub fn new() -> Self

Create a decoder with the default configuration

Source

pub fn with_config(config: DecoderConfig) -> Self

Create a decoder with a custom configuration

Source

pub fn template_count(&self) -> usize

Number of Templates and Options Templates in the cache

Source

pub fn has_template(&self, observation_domain_id: u32, template_id: u16) -> bool

Whether a Template (or Options Template) is known for this Observation Domain and Template ID

Source

pub fn template_last_received( &self, observation_domain_id: u32, template_id: u16, ) -> Option<u32>

Export Time of the Message that last carried this Template (or Options Template), i.e. the “Last Received” of RFC 7011 Section 8.4

Source

pub fn expire_templates(&mut self, now: u32)

Discard the Templates not refreshed within DecoderConfig::template_lifetime at time now (in seconds since the UNIX epoch, like the Export Time). This runs automatically for each decoded Message over UDP; call it to expire Templates with your own clock, e.g. when an Exporter stopped sending. Does nothing without a lifetime.

Source

pub fn register_enterprise_element( &mut self, element: EnterpriseElement, ) -> Result<()>

Register the definition of an enterprise-specific Information Element (e.g. from vendor documentation), so that its fields are decoded with its data type instead of being kept as FieldValue::Raw.

Registered definitions apply to all Observation Domains, survive clear, and always take precedence over type records sent by the Exporter (RFC 5610 Section 3.9). Registering the same element again replaces the definition. Fails for reverse elements (PEN 29305) and for IANA elements already in the registry.

Source

pub fn enterprise_element( &self, observation_domain_id: u32, enterprise_number: u32, id: u16, ) -> Option<&EnterpriseElement>

The definition of an enterprise-specific Information Element: the registered one, or else the one learned from type records (RFC 5610) in this Observation Domain. With enterprise_number 0, the definition of an IANA element newer than the registry.

Source

pub fn learned_element_count(&self) -> usize

Number of enterprise-specific Information Element definitions learned from type records (RFC 5610), excluding conflicting ones

Source

pub fn field_name( &self, observation_domain_id: u32, specifier: &FieldSpecifier, ) -> Option<&str>

The name of a field’s Information Element: the IANA name (forward name for reverse elements), or the name of its enterprise-specific definition

Source

pub fn clear(&mut self)

Remove all Templates and learned type records (e.g. at the end of the Transport Session). Registered definitions are kept.

Source

pub fn remove_observation_domain(&mut self, observation_domain_id: u32)

Remove all Templates and learned type records of an Observation Domain

Source

pub fn decode(&mut self, data: &[u8]) -> Result<Message>

Decode one IPFIX Message, updating the Template cache.

Octets after the Message Length are ignored; use decode_all for a buffer holding several Messages.

Source

pub fn decode_all(&mut self, data: &[u8]) -> Result<Vec<Message>>

Decode a buffer of consecutive IPFIX Messages (e.g. a TCP stream or an IPFIX File), updating the Template cache.

Trait Implementations§

Source§

impl Clone for Decoder

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Decoder

Source§

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

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

impl Default for Decoder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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, 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.