FieldValue

Enum FieldValue 

Source
pub enum FieldValue<'data> {
Show 14 variants UInt8(u8), UInt16(u16), UInt32(u32), UInt64(u64), Int64(i64), Bool(bool), IpAddr(IpAddr), MacAddr([u8; 6]), Str(&'data str), Bytes(&'data [u8]), OwnedString(CompactString), OwnedBytes(Vec<u8>), List(Vec<FieldValue<'data>>), Null,
}
Expand description

Possible field value types (maps to Arrow types).

FieldValue supports zero-copy parsing where possible:

  • Str and Bytes reference packet data directly
  • OwnedString and OwnedBytes are used when values must be constructed

The lifetime parameter 'data ties the value to the packet/buffer data.

Variants§

§

UInt8(u8)

Unsigned 8-bit integer

§

UInt16(u16)

Unsigned 16-bit integer

§

UInt32(u32)

Unsigned 32-bit integer

§

UInt64(u64)

Unsigned 64-bit integer

§

Int64(i64)

Signed 64-bit integer

§

Bool(bool)

Boolean value

§

IpAddr(IpAddr)

IP address (v4 or v6)

§

MacAddr([u8; 6])

MAC address (6 bytes)

§

Str(&'data str)

Zero-copy string reference into packet data. Use for strings that exist verbatim in the packet (e.g., TLS SNI, SSH version).

§

Bytes(&'data [u8])

Zero-copy byte slice reference into packet data. Use for payload or binary data that exists verbatim in the packet.

§

OwnedString(CompactString)

Owned string for constructed values (DNS names, joined lists, enum names). Uses CompactString for small-string optimization (inline up to 24 bytes).

§

OwnedBytes(Vec<u8>)

Owned bytes for constructed/decoded data.

§

List(Vec<FieldValue<'data>>)

List of values (for multi-valued fields like DNS answers). All elements should be of the same type. Note: Uses Vec because FieldValue is recursive (SmallVec inline storage causes infinite size).

§

Null

Null/missing value

Implementations§

Source§

impl<'data> FieldValue<'data>

Source

pub fn mac(bytes: &[u8]) -> Self

Create a MAC address from bytes.

Source

pub fn ipv4(bytes: &[u8]) -> Self

Create an IPv4 address from bytes.

Source

pub fn ipv6(bytes: &[u8]) -> Self

Create an IPv6 address from bytes.

Source

pub fn format_mac(mac: &[u8; 6]) -> String

Format a MAC address as a string.

Source

pub fn is_null(&self) -> bool

Check if this is a null value.

Source

pub fn as_u64(&self) -> Option<u64>

Try to get as u64.

Source

pub fn as_i64(&self) -> Option<i64>

Try to get as i64.

Source

pub fn as_u16(&self) -> Option<u16>

Try to get as u16.

Source

pub fn as_str(&self) -> Option<&str>

Try to get as str reference.

Source

pub fn as_bytes(&self) -> Option<&[u8]>

Try to get as bytes reference.

Source

pub fn as_string(&self) -> Option<String>

Try to get as string (owned, allocates).

Source

pub fn as_list(&self) -> Option<&[FieldValue<'data>]>

Try to get as list reference.

Source

pub fn list_len(&self) -> Option<usize>

Get the number of elements if this is a list, or None otherwise.

Source

pub fn to_owned(&self) -> FieldValue<'static>

Convert to an owned version (for caching). Copies borrowed data into owned variants.

Trait Implementations§

Source§

impl<'data> Clone for FieldValue<'data>

Source§

fn clone(&self) -> FieldValue<'data>

Returns a duplicate 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<'data> Debug for FieldValue<'data>

Source§

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

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

impl<'data> Display for FieldValue<'data>

Source§

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

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

impl<'a, 'b> PartialEq<FieldValue<'b>> for FieldValue<'a>

Source§

fn eq(&self, other: &FieldValue<'b>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl<'data> Freeze for FieldValue<'data>

§

impl<'data> RefUnwindSafe for FieldValue<'data>

§

impl<'data> Send for FieldValue<'data>

§

impl<'data> Sync for FieldValue<'data>

§

impl<'data> Unpin for FieldValue<'data>

§

impl<'data> UnwindSafe for FieldValue<'data>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToCompactString for T
where T: Display,

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more