Skip to main content

FieldFormatter

Struct FieldFormatter 

Source
pub struct FieldFormatter<'f> { /* private fields */ }
Expand description

A Formatter for filling a particular TTLV field.

A Formatter can delegate to a FieldFormatter to format a TTLV field such as a structure. This provides an incremental API to fill the field.

Implementations§

Source§

impl FieldFormatter<'_>

Source

pub fn finish(self) -> FormatDone

Successfully finish formatting.

Methods from Deref<Target = Formatter<'f>>§

Source

pub fn clear(&mut self)

Source

pub fn filled(&self) -> &[[u8; 8]]

The filled part of the buffer.

Source

pub fn filled_mut(&mut self) -> &mut [[u8; 8]]

The filled part of the buffer, mutably.

Source

pub fn remaining(&mut self) -> &mut [MaybeUninit<[u8; 8]>]

The remaining part of the buffer.

Source

pub fn format_struct( &mut self, tag: Tag, ) -> Result<FieldFormatter<'_>, TruncationError>

Format a structure.

The returned sub-formatter should be used to format the fields of the struct; once it is finished, self can continue.

Source

pub fn format_int(&mut self, tag: Tag, value: i32) -> FormatResult

Format an integer.

Source

pub fn format_long_int(&mut self, tag: Tag, value: i64) -> FormatResult

Format a long integer.

Source

pub fn format_big_int(&mut self, tag: Tag, value: &[u8]) -> FormatResult

Format a big integer.

value should be the bytewise digits of a signed (two’s complement) big-endian integer. It will be padded (with leading sign-extension bytes) into a multiple of 8 bytes before being stored.

§Panics

Panics if the length of value (when rounded up to a multiple of 8 bytes) does not fit in a u32.

Source

pub fn format_enum(&mut self, tag: Tag, value: u32) -> FormatResult

Format an enumeration.

Source

pub fn format_bool(&mut self, tag: Tag, value: bool) -> FormatResult

Format a boolean.

Source

pub fn format_text(&mut self, tag: Tag, value: &str) -> FormatResult

Format a text string.

Source

pub fn format_bytes(&mut self, tag: Tag, value: &[u8]) -> FormatResult

Format a byte string.

Source

pub fn format_date_time(&mut self, tag: Tag, value: i64) -> FormatResult

Format a date-time.

Source

pub fn format_interval(&mut self, tag: Tag, value: u32) -> FormatResult

Format an interval.

Trait Implementations§

Source§

impl<'f> Deref for FieldFormatter<'f>

Source§

type Target = Formatter<'f>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'f> DerefMut for FieldFormatter<'f>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<'f> !UnwindSafe for FieldFormatter<'f>

§

impl<'f> Forget for FieldFormatter<'f>

§

impl<'f> Freeze for FieldFormatter<'f>

§

impl<'f> Move for FieldFormatter<'f>

§

impl<'f> RefUnwindSafe for FieldFormatter<'f>

§

impl<'f> Send for FieldFormatter<'f>

§

impl<'f> Sync for FieldFormatter<'f>

§

impl<'f> Unpin for FieldFormatter<'f>

§

impl<'f> UnsafeUnpin for FieldFormatter<'f>

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> 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.
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