pub struct Uvar(_);
Implementations
sourceimpl Uvar
impl Uvar
sourcepub fn new(bytes: Vec<u8>) -> Uvar
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.
sourcepub fn to_bytes(self) -> Vec<u8> ⓘ
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]);
sourcepub fn from_bytes(buffer: &[u8]) -> Result<Uvar, UvarError>
pub fn from_bytes(buffer: &[u8]) -> Result<Uvar, UvarError>
Transforms a byte list into a uvar.
sourcepub fn take(buffer: &[u8]) -> Result<(Uvar, &[u8]), UvarError>
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
sourceimpl From<Blake2b512> for Uvar
impl From<Blake2b512> for Uvar
sourcefn from(hash: Blake2b512) -> Uvar
fn from(hash: Blake2b512) -> Uvar
Converts to this type from the input type.
sourceimpl From<Blake2s256> for Uvar
impl From<Blake2s256> for Uvar
sourcefn from(hash: Blake2s256) -> Uvar
fn from(hash: Blake2s256) -> Uvar
Converts to this type from the input type.
sourceimpl From<Uvar> for Result<Blake2b512, MultihashError>
impl From<Uvar> for Result<Blake2b512, MultihashError>
sourcefn from(code: Uvar) -> Result<Blake2b512, MultihashError>
fn from(code: Uvar) -> Result<Blake2b512, MultihashError>
Converts to this type from the input type.
sourceimpl From<Uvar> for Result<Blake2s256, MultihashError>
impl From<Uvar> for Result<Blake2s256, MultihashError>
sourcefn from(code: Uvar) -> Result<Blake2s256, MultihashError>
fn from(code: Uvar) -> Result<Blake2s256, MultihashError>
Converts to this type from the input type.
sourceimpl From<u64> for Uvar
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.
impl StructuralPartialEq for Uvar
Auto Trait Implementations
impl RefUnwindSafe for Uvar
impl Send for Uvar
impl Sync for Uvar
impl Unpin for Uvar
impl UnwindSafe for Uvar
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more