Skip to main content

Field

Struct Field 

Source
pub struct Field {
    pub name: Arc<str>,
    pub value: Arc<str>,
    pub indent: u8,
    pub span: (usize, usize),
}
Expand description

A field with its name, value, byte span, and indent level.

Fields represent individual pieces of parsed data within a packet. They form a hierarchy with three indent levels:

  • Level 0: Packet headers
  • Level 1: Top-level fields within a packet
  • Level 2: Nested subfields (e.g., signature subpackets)

§Visualization

The span field supports hex dump visualization, allowing UI code to highlight the corresponding bytes and assign colors as needed.

Fields§

§name: Arc<str>

The field name (e.g., “Version”, “Algorithm”, “Creation Time”).

§value: Arc<str>

The field value as a human-readable string.

§indent: u8

Indentation level: 0 = packet, 1 = field, 2 = subfield.

§span: (usize, usize)

Byte range (start, end) in the original data.

Implementations§

Source§

impl Field

Source

pub fn new( name: impl Into<Arc<str>>, value: impl Into<Arc<str>>, indent: u8, span: (usize, usize), ) -> Self

Creates a new field with all parameters specified.

Source

pub fn packet( name: impl Into<Arc<str>>, value: impl Into<Arc<str>>, span: (usize, usize), ) -> Self

Creates a packet-level field (indent 0).

Used for packet type headers like “Packet: Public Key”.

Source

pub fn field( name: impl Into<Arc<str>>, value: impl Into<Arc<str>>, span: (usize, usize), ) -> Self

Creates a regular field (indent 1).

Used for top-level packet fields like “Version”, “Algorithm”.

Source

pub fn subfield( name: impl Into<Arc<str>>, value: impl Into<Arc<str>>, span: (usize, usize), ) -> Self

Creates a subfield (indent 2).

Used for nested data like signature subpackets.

Trait Implementations§

Source§

impl Clone for Field

Source§

fn clone(&self) -> Field

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 Field

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Field

§

impl RefUnwindSafe for Field

§

impl Send for Field

§

impl Sync for Field

§

impl Unpin for Field

§

impl UnsafeUnpin for Field

§

impl UnwindSafe for Field

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

Source§

type Output = T

Should always be Self
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 = 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.