Struct AB

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

newtype around bytes to print/parse [[abe]] text

Tuple Fields§

§0: N

Implementations§

§

impl AB<[u8; 2]>

pub fn uint(self) -> U16

§

impl AB<[u8; 4]>

pub fn uint(self) -> U32

§

impl AB<[u8; 8]>

pub fn uint(self) -> U64

§

impl AB<[u8; 16]>

pub fn uint(self) -> U128

§

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

pub fn from_ref(b: &N) -> &AB<N>

§

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

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

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

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

pub fn x_prefix_cut(&self) -> (bool, &[u8])

§

impl AB<&[u8]>

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

§

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

pub fn try_from_exact(slice: &[u8]) -> Result<AB<[u8; L]>, MatchErrorKind>

pub fn slice_into_bytes(slice: &[AB<[u8; L]>]) -> &[u8]

pub fn slice_from_bytes( slice: &[u8], ) -> Result<&[AB<[u8; L]>], (&[AB<[u8; L]>], &[u8])>

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

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

Self::utf8 but fallback to abtxt

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

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

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

pub const fn try_join( head: &[u8], tail: &[u8], ) -> Result<AB<[u8; L]>, FitSliceErr>

Join head and tail with padding between

pub fn split<const H: usize, const T: usize>(self) -> ([u8; H], [u8; T])

§

impl AB<[u8; 16]>

pub const fn to_u128(self) -> u128

pub const fn from_u128(value: u128) -> AB<[u8; 16]>

Trait Implementations§

§

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

§

fn check(b: &[ABE]) -> Result<(), MatchError>

§

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

§

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

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

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

§

fn as_ref(&self) -> &N

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

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

§

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

Immutably borrows from an owned value. Read more
§

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

§

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
§

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

§

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

Formats the value using the given formatter. Read more
§

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

§

fn default() -> AB<N>

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

impl<N> Deref for AB<N>

§

type Target = N

The resulting type after dereferencing.
§

fn deref(&self) -> &<AB<N> as Deref>::Target

Dereferences the value.
§

impl<N> DerefMut for AB<N>

§

fn deref_mut(&mut self) -> &mut <AB<N> as Deref>::Target

Mutably dereferences the value.
§

impl<'de> Deserialize<'de> for AB

§

fn deserialize<D>( deserializer: D, ) -> Result<AB, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl<'de, const N: usize> Deserialize<'de> for AB<[u8; N]>

§

fn deserialize<D>( deserializer: D, ) -> Result<AB<[u8; N]>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

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

§

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

Formats the value using the given formatter. Read more
§

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

§

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

Converts to this type from the input type.
§

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

§

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

Converts to this type from the input type.
§

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

§

fn from(v: N) -> AB<N>

Converts to this type from the input type.
§

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

§

fn from(value: u128) -> AB<[u8; 16]>

Converts to this type from the input type.
§

impl FromStr for AB

§

type Err = ABTxtError

The associated error which can be returned from parsing.
§

fn from_str(s: &str) -> Result<AB, <AB as FromStr>::Err>

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

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

§

type Err = ABTxtError

The associated error which can be returned from parsing.
§

fn from_str(s: &str) -> Result<AB<[u8; N]>, <AB<[u8; N]> as FromStr>::Err>

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

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

§

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

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

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

§

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

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
§

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

§

fn eq(&self, other: &AB<N>) -> 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.
§

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

§

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

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

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

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

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

impl<B> Serialize for AB<B>
where B: AsRef<[u8]>,

§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

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

§

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

§

fn write_abe_str(&self, out: &mut dyn Write) -> Result<(), Error>

§

fn to_abe_str(&self) -> String

§

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

§

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

§

type Error = FitSliceErr

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

fn try_from( value: &[u8], ) -> Result<AB<[u8; L]>, <AB<[u8; L]> as TryFrom<&[u8]>>::Error>

Performs the conversion.
§

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

§

type Error = FitSliceErr

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

fn try_from( value: ABList, ) -> Result<AB<[u8; L]>, <AB<[u8; L]> as TryFrom<ABList>>::Error>

Performs the conversion.
§

impl UInt for AB<[u8; 16]>

§

const MIN: AB<[u8; 16]>

§

const MAX: AB<[u8; 16]>

§

const ONE: AB<[u8; 16]>

§

const BITS: u32 = 128u32

§

const BYTE_SIZE: usize = 16usize

§

fn as_be_bytes(&self, out: &mut dyn FnMut(&[u8]))

§

fn bit_and(self, other: AB<[u8; 16]>) -> AB<[u8; 16]>

§

fn bit_or(self, other: AB<[u8; 16]>) -> AB<[u8; 16]>

§

fn not(self) -> AB<[u8; 16]>

§

fn inc(self) -> Option<AB<[u8; 16]>>

§

fn decr(self) -> Option<AB<[u8; 16]>>

§

fn overflowing_add(self, rhs: AB<[u8; 16]>) -> (AB<[u8; 16]>, bool)

§

fn checked_sub(self, other: AB<[u8; 16]>) -> Option<AB<[u8; 16]>>

§

fn checked_add(self, other: AB<[u8; 16]>) -> Option<AB<[u8; 16]>>

§

fn overflowing_shl(self, rhs: u32) -> (AB<[u8; 16]>, bool)

§

fn overflowing_shr(self, rhs: u32) -> (AB<[u8; 16]>, bool)

§

fn leading_zeros(&self) -> u32

§

fn trailing_zeros(&self) -> u32

§

fn trailing_ones(&self) -> u32

§

fn leading_ones(&self) -> u32

§

fn to_be_vec(&self) -> Vec<u8>

§

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

§

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

§

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

Auto Trait Implementations§

§

impl<N> Freeze for AB<N>
where N: Freeze + ?Sized,

§

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

§

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

§

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

§

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

§

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

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

Source§

fn from(t: !) -> T

Converts to this type from the input type.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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> 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> 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,