Struct FixedWidthUint

Source
pub struct FixedWidthUint<'a, T: FixedWidthEncoding + ?Sized>(/* private fields */);
Expand description

A fixed width encodable unsigned integer

Trait Implementations§

Source§

impl<T: FixedWidthEncoding> CompactEncoding<<T as FixedWidthEncoding>::Decode> for FixedWidthUint<'_, T>

Source§

fn encoded_size(&self) -> Result<usize, EncodingError>

The size in bytes required to encode self.
Source§

fn encode<'a>( &self, buffer: &'a mut [u8], ) -> Result<&'a mut [u8], EncodingError>

Encode self into buffer returning the remainder of buffer.
Source§

fn decode(buffer: &[u8]) -> Result<(T::Decode, &[u8]), EncodingError>
where Self: Sized,

Decode a value from the given buffer of the type specified by the Decode type parameter (which defaults to Self). Returns the decoded value and remaining undecoded bytes.
Source§

fn to_encoded_bytes(&self) -> Result<Box<[u8]>, EncodingError>

Encode self into a Vec<u8>. This is just a helper method for creating a buffer and encoding to it in one step. Read more
Source§

fn create_buffer(&self) -> Result<Box<[u8]>, EncodingError>

Create an empty buffer of the correct size for encoding self to. This is just a helper method for: encoding to it in one step. Read more
Source§

fn encode_with_len<'a>( &self, buffer: &'a mut [u8], ) -> Result<(&'a mut [u8], usize), EncodingError>

Like CompactEncoding::encode but also return the number of bytes encoded.
Source§

fn decode_with_len( buffer: &[u8], ) -> Result<(Decode, &[u8], usize), EncodingError>
where Decode: Sized,

Like CompactEncoding::decode but also return the number of bytes decoded.
Source§

impl<'a, T: Debug + FixedWidthEncoding + ?Sized> Debug for FixedWidthUint<'a, T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, T> Freeze for FixedWidthUint<'a, T>
where T: ?Sized,

§

impl<'a, T> RefUnwindSafe for FixedWidthUint<'a, T>
where T: RefUnwindSafe + ?Sized,

§

impl<'a, T> Send for FixedWidthUint<'a, T>
where T: Sync + ?Sized,

§

impl<'a, T> Sync for FixedWidthUint<'a, T>
where T: Sync + ?Sized,

§

impl<'a, T> Unpin for FixedWidthUint<'a, T>
where T: ?Sized,

§

impl<'a, T> UnwindSafe for FixedWidthUint<'a, T>
where T: RefUnwindSafe + ?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> 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, 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.