Struct byte_fmt::AB

source ·
#[repr(transparent)]
pub struct AB<N: ?Sized = Vec<u8>>(pub N);
Expand description

newtype around bytes to print/parse [abe] text

Tuple Fields§

§0: N

Implementations§

source§

impl AB<[u8; 2]>

source

pub fn uint(self) -> U16

source§

impl AB<[u8; 4]>

source

pub fn uint(self) -> U32

source§

impl AB<[u8; 8]>

source

pub fn uint(self) -> U64

source§

impl AB<[u8; 16]>

source

pub fn uint(self) -> U128

source§

impl<N> AB<N>where Self: AsRef<[u8]>,

source

pub fn cut_prefix_nulls(&self) -> &[u8]

source

pub fn as_ref_cut(&self, cut_nulls: bool) -> &[u8]

source

pub fn as_str(&self, cut_nulls: bool) -> Cow<'_, str>

source§

impl<'o> AB<&'o [u8]>

source

pub fn parse_ctx<V>(&self) -> Result<V, ParseErr<<V as FromStr>::Err>>where V: FromStr, <V as FromStr>::Err: Error,

source

pub fn parse<V>(&self) -> Result<V, <V as FromStr>::Err>where V: FromStr,

source§

impl<const L: usize> AB<[u8; L]>

source

pub fn utf8(&self) -> Result<&str, Utf8Error>

source

pub fn try_utf8(&self) -> Cow<'_, str>

Self::utf8 but fallback to abtxt

source

pub const fn try_fit_byte_slice(slice: &[u8]) -> Result<Self, FitSliceErr>

source

pub const fn try_fit_slice_filled<const FILL: u8>( slice: &[u8] ) -> Result<Self, FitSliceErr>

source

pub fn parse_abtxt(st: impl AsRef<[u8]>) -> Result<Self, ABTxtError>

source§

impl AB<[u8; 16]>

source

pub const fn to_u128(self) -> u128

source

pub const fn from_u128(value: u128) -> Self

Trait Implementations§

source§

impl<const L: usize> ABEValidator for AB<[u8; L]>

source§

impl<N: AsRef<[u8]>> AsRef<[u8]> for AB<N>

source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<N> AsRef<N> for AB<N>

source§

fn as_ref(&self) -> &N

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<N: Borrow<[u8]>> Borrow<[u8]> for AB<N>

source§

fn borrow(&self) -> &[u8]

Immutably borrows from an owned value. Read more
source§

impl<N: Clone + ?Sized> Clone for AB<N>

source§

fn clone(&self) -> AB<N>

Returns a copy 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<X> Debug for AB<X>where Self: AsRef<[u8]>,

source§

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

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

impl<N: Default + ?Sized> Default for AB<N>

source§

fn default() -> AB<N>

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

impl<N> Deref for AB<N>

§

type Target = N

The resulting type after dereferencing.
source§

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

Dereferences the value.
source§

impl<N> DerefMut for AB<N>

source§

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

Mutably dereferences the value.
source§

impl<X> Display for AB<X>where Self: AsRef<[u8]>,

source§

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

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

impl<'o> From<&'o [u8]> for &'o AB<[u8]>

source§

fn from(d: &'o [u8]) -> Self

Converts to this type from the input type.
source§

impl From<AB<[u8; 16]>> for u128

source§

fn from(val: AB<[u8; 16]>) -> Self

Converts to this type from the input type.
source§

impl<N> From<AB<N>> for ABListwhere AB<N>: AsRef<[u8]>,

source§

fn from(val: AB<N>) -> Self

Converts to this type from the input type.
source§

impl<N> From<N> for AB<N>

source§

fn from(v: N) -> Self

Converts to this type from the input type.
source§

impl From<u128> for AB<[u8; 16]>

source§

fn from(value: u128) -> Self

Converts to this type from the input type.
source§

impl<const N: usize> FromStr for AB<[u8; N]>

§

type Err = ABTxtError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl FromStr for AB<Vec<u8>>

§

type Err = ABTxtError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
source§

impl<N: Hash + ?Sized> Hash for AB<N>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
source§

impl<N: Ord + ?Sized> Ord for AB<N>

source§

fn cmp(&self, other: &AB<N>) -> Ordering

This method returns an Ordering between self and other. Read more
source§

impl<N: PartialEq + ?Sized> PartialEq<AB<N>> for AB<N>

source§

fn eq(&self, other: &AB<N>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<N: PartialOrd + ?Sized> PartialOrd<AB<N>> for AB<N>

source§

fn partial_cmp(&self, other: &AB<N>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<N> ToABE for AB<N>where Self: AsRef<[u8]>,

source§

fn write_abe(&self, out: &mut dyn FnMut(ABE))

source§

fn to_abe_str(&self) -> String

source§

fn to_abe(&self) -> Vec<ABE, Global>

source§

impl<const L: usize> TryFrom<&[u8]> for AB<[u8; L]>

§

type Error = FitSliceErr

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

fn try_from(value: &[u8]) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<const L: usize> TryFrom<ABList> for AB<[u8; L]>

§

type Error = FitSliceErr

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

fn try_from(value: ABList) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<N: Copy + ?Sized> Copy for AB<N>

source§

impl<N: Eq + ?Sized> Eq for AB<N>

source§

impl<N: ?Sized> StructuralEq for AB<N>

source§

impl<N: ?Sized> StructuralPartialEq for AB<N>

Auto Trait Implementations§

§

impl<N: ?Sized> RefUnwindSafe for AB<N>where N: RefUnwindSafe,

§

impl<N: ?Sized> Send for AB<N>where N: Send,

§

impl<N: ?Sized> Sync for AB<N>where N: Sync,

§

impl<N: ?Sized> Unpin for AB<N>where N: Unpin,

§

impl<N: ?Sized> UnwindSafe for AB<N>where N: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<!> for T

const: unstable · source§

fn from(t: !) -> T

Converts to this type from the input type.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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 Twhere T: Clone,

§

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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.