Uvar

Struct Uvar 

Source
pub struct Uvar(/* private fields */);

Implementations§

Source§

impl Uvar

Source

pub fn new(bytes: Vec<u8>) -> Uvar

Constructs a new uvar from a byte list. Use {Uvar::from_bytes} if you need a safe constructor.

Source

pub fn to_bytes(self) -> Vec<u8>

Consumes the list of bytes.

use blot::uvar::Uvar;

assert_eq!(Uvar::from_bytes(&[0x12]).unwrap().to_bytes(), vec![0x12]);
Source

pub fn from_bytes(buffer: &[u8]) -> Result<Uvar, UvarError>

Transforms a byte list into a uvar.

Source

pub fn take(buffer: &[u8]) -> Result<(Uvar, &[u8]), UvarError>

Takes a uvar from a list of bytes and returns it with the rest of bytes.

use blot::uvar::Uvar;

let buffer = vec![0x12, 0x07, 0x06];
let (uvar, bytes) = Uvar::take(&buffer).unwrap();

assert_eq!(uvar, Uvar::from_bytes(&[0x12]).unwrap());

Trait Implementations§

Source§

impl Binary for Uvar

Source§

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

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

impl Clone for Uvar

Source§

fn clone(&self) -> Uvar

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 Debug for Uvar

Source§

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

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

impl Display for Uvar

Source§

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

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

impl From<Blake2b512> for Uvar

Source§

fn from(hash: Blake2b512) -> Uvar

Converts to this type from the input type.
Source§

impl From<Blake2s256> for Uvar

Source§

fn from(hash: Blake2s256) -> Uvar

Converts to this type from the input type.
Source§

impl From<Sha1> for Uvar

Source§

fn from(hash: Sha1) -> Uvar

Converts to this type from the input type.
Source§

impl From<Sha2256> for Uvar

Source§

fn from(hash: Sha2256) -> Uvar

Converts to this type from the input type.
Source§

impl From<Sha2512> for Uvar

Source§

fn from(hash: Sha2512) -> Uvar

Converts to this type from the input type.
Source§

impl From<Sha3224> for Uvar

Source§

fn from(hash: Sha3224) -> Uvar

Converts to this type from the input type.
Source§

impl From<Sha3256> for Uvar

Source§

fn from(hash: Sha3256) -> Uvar

Converts to this type from the input type.
Source§

impl From<Sha3384> for Uvar

Source§

fn from(hash: Sha3384) -> Uvar

Converts to this type from the input type.
Source§

impl From<Sha3512> for Uvar

Source§

fn from(hash: Sha3512) -> Uvar

Converts to this type from the input type.
Source§

impl From<Uvar> for Result<Blake2b512, MultihashError>

Source§

fn from(code: Uvar) -> Result<Blake2b512, MultihashError>

Converts to this type from the input type.
Source§

impl From<Uvar> for Result<Blake2s256, MultihashError>

Source§

fn from(code: Uvar) -> Result<Blake2s256, MultihashError>

Converts to this type from the input type.
Source§

impl From<Uvar> for Result<Sha1, MultihashError>

Source§

fn from(code: Uvar) -> Result<Sha1, MultihashError>

Converts to this type from the input type.
Source§

impl From<Uvar> for Result<Sha2256, MultihashError>

Source§

fn from(code: Uvar) -> Result<Sha2256, MultihashError>

Converts to this type from the input type.
Source§

impl From<Uvar> for Result<Sha2512, MultihashError>

Source§

fn from(code: Uvar) -> Result<Sha2512, MultihashError>

Converts to this type from the input type.
Source§

impl From<Uvar> for Result<Sha3224, MultihashError>

Source§

fn from(code: Uvar) -> Result<Sha3224, MultihashError>

Converts to this type from the input type.
Source§

impl From<Uvar> for Result<Sha3256, MultihashError>

Source§

fn from(code: Uvar) -> Result<Sha3256, MultihashError>

Converts to this type from the input type.
Source§

impl From<Uvar> for Result<Sha3384, MultihashError>

Source§

fn from(code: Uvar) -> Result<Sha3384, MultihashError>

Converts to this type from the input type.
Source§

impl From<Uvar> for Result<Sha3512, MultihashError>

Source§

fn from(code: Uvar) -> Result<Sha3512, MultihashError>

Converts to this type from the input type.
Source§

impl From<Uvar> for u64

Source§

fn from(uvar: Uvar) -> u64

Converts to this type from the input type.
Source§

impl From<u64> for Uvar

This conversion consumes full bytes, not 7bit bytes as you would expect from variable integers.

WARNING: This method forces to Big Endian. It hasn’t been tested properly with different architectures.

Source§

fn from(n: u64) -> Uvar

Converts to this type from the input type.
Source§

impl LowerHex for Uvar

Source§

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

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

impl PartialEq for Uvar

Source§

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

impl UpperHex for Uvar

Source§

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

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

impl StructuralPartialEq for Uvar

Auto Trait Implementations§

§

impl Freeze for Uvar

§

impl RefUnwindSafe for Uvar

§

impl Send for Uvar

§

impl Sync for Uvar

§

impl Unpin for Uvar

§

impl UnwindSafe for Uvar

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