Struct DisplayBytesConfig

Source
pub struct DisplayBytesConfig<'d, F> { /* private fields */ }
Expand description

Configuration builder for DisplayBytes.

Consts with sane defaults are provided in this module.

Implementations§

Source§

impl<'d, F> DisplayBytesConfig<'d, F>

Source

pub fn byte_format<F_: ByteFormat>( self, format: F_, ) -> DisplayBytesConfig<'d, F_>

Set the type used to format byte sequences.

Source

pub fn byte_format_mut(&mut self) -> &mut F

Get a mutable reference to the current ByteFormat.

Source

pub fn delimiters<'d_>( self, delimiters: [&'d_ str; 2], ) -> DisplayBytesConfig<'d_, F>

Set the pair of delimiters used to wrap byte sequences in the formatted stream.

Note that this can change the lifetime bound.

Source

pub fn delimiters_mut(&mut self) -> &mut [&'d str; 2]

Get a mutable reference to the current pair of delimiters.

Source

pub fn ascii_only(self, ascii_only: bool) -> Self

If set to true, only displays ASCII byte sequences (bytes in [0x00, 0x7F]).

Otherwise, displays all valid UTF-8 sequences at least min_str_len bytes long.

Source

pub fn min_str_len(self, min_str_len: usize) -> Self

The minimum number of bytes in length that a valid string sequence must be to be displayed.

Strings shorter than this length will be included in the nearest byte sequence. Use this to avoid extra noise from random decodable characters splitting byte sequences.

§Note

This does not affect byte sequences that can be completely decoded. If print_terminators is set, this also will not affect strings at the beginning or at the end of the byte slice (e.g. valid strings at the start and end will be printed regardless of length).

Source

pub fn print_terminators(self, print_terminators: bool) -> Self

If set to true, valid strings at the start and end of a byte slice will be printed regardless of their length relative to min_str_len.

Source

pub fn escape_control(self, escape_ctl: bool) -> Self

If set to true, control characters will be printed in their escaped form (\n) instead of printed directly.

Source

pub fn invert_delimiters(self, invert_delimiters: bool) -> Self

If set to true, wraps decoded strings in the given delimiters rather than byte sequences.

Source§

impl<'d, F: ByteFormat> DisplayBytesConfig<'d, F>

Source

pub fn display_bytes_string<'b>(&self, bytes: &'b [u8]) -> Cow<'b, str>
where F: 'b, 'd: 'b,

Attempt to convert bytes to a string (an ASCII-only string if ascii_only is set, UTF-8 otherwise), or otherwise format bytes to a string using the properties in this configuration.

Source

pub fn ref_display_bytes<'b>(&'b self, bytes: &'b [u8]) -> DisplayBytes<'b, F>

Get a type that implements Display which will format bytes to an output stream using the properties in this configuration.

Source§

impl<'d, F: ByteFormat> DisplayBytesConfig<'d, F>

Source

pub fn display_bytes<'b>(self, bytes: &'b [u8]) -> DisplayBytes<'b, F>
where 'd: 'b,

Get a type that implements Display which will format bytes to an output stream using the properties in this configuration.

Trait Implementations§

Source§

impl<'d, F: Clone> Clone for DisplayBytesConfig<'d, F>

Source§

fn clone(&self) -> DisplayBytesConfig<'d, F>

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<'d, F: Debug> Debug for DisplayBytesConfig<'d, F>

Source§

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

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

impl Default for DisplayBytesConfig<'static, FormatBase64>

Source§

fn default() -> Self

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

impl Default for DisplayBytesConfig<'static, FormatHex<'static>>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<'d, F> Freeze for DisplayBytesConfig<'d, F>
where F: Freeze,

§

impl<'d, F> RefUnwindSafe for DisplayBytesConfig<'d, F>
where F: RefUnwindSafe,

§

impl<'d, F> Send for DisplayBytesConfig<'d, F>
where F: Send,

§

impl<'d, F> Sync for DisplayBytesConfig<'d, F>
where F: Sync,

§

impl<'d, F> Unpin for DisplayBytesConfig<'d, F>
where F: Unpin,

§

impl<'d, F> UnwindSafe for DisplayBytesConfig<'d, F>
where F: UnwindSafe,

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 = 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.