pub struct Uvar(/* private fields */);Implementations§
Source§impl 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§
Source§impl From<Blake2b512> for Uvar
impl From<Blake2b512> for Uvar
Source§fn from(hash: Blake2b512) -> Uvar
fn from(hash: Blake2b512) -> Uvar
Converts to this type from the input type.
Source§impl From<Blake2s256> for Uvar
impl From<Blake2s256> for Uvar
Source§fn from(hash: Blake2s256) -> Uvar
fn from(hash: Blake2s256) -> Uvar
Converts to this type from the input type.
Source§impl From<Uvar> for Result<Blake2b512, MultihashError>
impl From<Uvar> for Result<Blake2b512, MultihashError>
Source§fn from(code: Uvar) -> Result<Blake2b512, MultihashError>
fn from(code: Uvar) -> Result<Blake2b512, MultihashError>
Converts to this type from the input type.
Source§impl From<Uvar> for Result<Blake2s256, MultihashError>
impl From<Uvar> for Result<Blake2s256, MultihashError>
Source§fn from(code: Uvar) -> Result<Blake2s256, MultihashError>
fn from(code: Uvar) -> Result<Blake2s256, MultihashError>
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.
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 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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more