pub struct CompactSize;
Expand description
Namespace for functions for compact encoding of integers.
This codec requires integers to be in the range 0x0..=0x02000000
, for compatibility
with Zcash consensus rules.
Implementations§
Source§impl CompactSize
impl CompactSize
Sourcepub fn read_t<R: Read, T: TryFrom<u64>>(reader: R) -> Result<T>
pub fn read_t<R: Read, T: TryFrom<u64>>(reader: R) -> Result<T>
Reads an integer encoded in contact form and performs checked conversion to the target type.
Sourcepub fn write<W: Write>(writer: W, size: usize) -> Result<()>
pub fn write<W: Write>(writer: W, size: usize) -> Result<()>
Writes the provided usize
value to the provided Writer in compact form.
Sourcepub fn serialized_size(size: usize) -> usize
pub fn serialized_size(size: usize) -> usize
Returns the number of bytes needed to encode the given size in compact form.
Auto Trait Implementations§
impl Freeze for CompactSize
impl RefUnwindSafe for CompactSize
impl Send for CompactSize
impl Sync for CompactSize
impl Unpin for CompactSize
impl UnwindSafe for CompactSize
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