Struct binout::VByte

source ·
pub struct VByte;
Expand description

Serializer that uses improved VByte/LEB128 encoding.

The encoding is identical to the classic VByte/LEB128 for u16 and u32 values. However:

  • u8 value are always stored as is, using 1 byte.
  • For u64 values below 263, the encoding is identical to the classic VByte/LEB128; For larger values, the encoding always stores the most significant byte of value as is, using a total of 9 bytes, whereas a classic VByte could use 10 bytes.

Trait Implementations§

source§

impl Clone for VByte

source§

fn clone(&self) -> VByte

Returns a copy 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 Serializer<u16> for VByte

source§

fn size(val: u16) -> usize

Returns number of bytes which write needs to serialize val.
source§

fn write<W: Write + ?Sized>(output: &mut W, val: u16) -> Result<()>

Serialize val to the given output.
source§

fn read<R: Read + ?Sized>(input: &mut R) -> Result<u16>

Deserialize value from the given input.
source§

const CONST_SIZE: Option<usize> = None

Either size of each value in bytes (if each value occupies constant size) or None.
source§

fn write_all_values<W, InIter>(output: &mut W, values: InIter) -> Result<()>
where W: Write + ?Sized, InIter: IntoIterator<Item = T>,

Serialize all values into the given output.
source§

fn write_all<'a, W, InIter>(output: &mut W, values: InIter) -> Result<()>
where W: Write + ?Sized, InIter: IntoIterator<Item = &'a T>, T: 'a,

Serialize all values into the given output.
source§

fn array_content_size(array: &[T]) -> usize

Returns number of bytes occupied by serialized content of the array.
source§

fn array_size(array: &[T]) -> usize

Returns number of bytes which write_array needs to serialize array.
source§

fn write_array<W: Write + ?Sized>(output: &mut W, array: &[T]) -> Result<()>

Serialize array to the given input. Size of the array is serialized in VByte format.
source§

fn read_n<R: Read + ?Sized>(input: &mut R, n: usize) -> Result<Box<[T]>>

Deserialize n values from the given input.
source§

fn read_array<R: Read + ?Sized>(input: &mut R) -> Result<Box<[T]>>

Deserialize array from the given input. Size of the array is serialized in VByte format.
source§

impl Serializer<u32> for VByte

source§

fn size(val: u32) -> usize

Returns number of bytes which write needs to serialize val.
source§

fn write<W: Write + ?Sized>(output: &mut W, val: u32) -> Result<()>

Serialize val to the given output.
source§

fn read<R: Read + ?Sized>(input: &mut R) -> Result<u32>

Deserialize value from the given input.
source§

const CONST_SIZE: Option<usize> = None

Either size of each value in bytes (if each value occupies constant size) or None.
source§

fn write_all_values<W, InIter>(output: &mut W, values: InIter) -> Result<()>
where W: Write + ?Sized, InIter: IntoIterator<Item = T>,

Serialize all values into the given output.
source§

fn write_all<'a, W, InIter>(output: &mut W, values: InIter) -> Result<()>
where W: Write + ?Sized, InIter: IntoIterator<Item = &'a T>, T: 'a,

Serialize all values into the given output.
source§

fn array_content_size(array: &[T]) -> usize

Returns number of bytes occupied by serialized content of the array.
source§

fn array_size(array: &[T]) -> usize

Returns number of bytes which write_array needs to serialize array.
source§

fn write_array<W: Write + ?Sized>(output: &mut W, array: &[T]) -> Result<()>

Serialize array to the given input. Size of the array is serialized in VByte format.
source§

fn read_n<R: Read + ?Sized>(input: &mut R, n: usize) -> Result<Box<[T]>>

Deserialize n values from the given input.
source§

fn read_array<R: Read + ?Sized>(input: &mut R) -> Result<Box<[T]>>

Deserialize array from the given input. Size of the array is serialized in VByte format.
source§

impl Serializer<u64> for VByte

source§

fn size(val: u64) -> usize

Returns number of bytes which write needs to serialize val.
source§

fn write<W: Write + ?Sized>(output: &mut W, val: u64) -> Result<()>

Serialize val to the given output.
source§

fn read<R: Read + ?Sized>(input: &mut R) -> Result<u64>

Deserialize value from the given input.
source§

const CONST_SIZE: Option<usize> = None

Either size of each value in bytes (if each value occupies constant size) or None.
source§

fn write_all_values<W, InIter>(output: &mut W, values: InIter) -> Result<()>
where W: Write + ?Sized, InIter: IntoIterator<Item = T>,

Serialize all values into the given output.
source§

fn write_all<'a, W, InIter>(output: &mut W, values: InIter) -> Result<()>
where W: Write + ?Sized, InIter: IntoIterator<Item = &'a T>, T: 'a,

Serialize all values into the given output.
source§

fn array_content_size(array: &[T]) -> usize

Returns number of bytes occupied by serialized content of the array.
source§

fn array_size(array: &[T]) -> usize

Returns number of bytes which write_array needs to serialize array.
source§

fn write_array<W: Write + ?Sized>(output: &mut W, array: &[T]) -> Result<()>

Serialize array to the given input. Size of the array is serialized in VByte format.
source§

fn read_n<R: Read + ?Sized>(input: &mut R, n: usize) -> Result<Box<[T]>>

Deserialize n values from the given input.
source§

fn read_array<R: Read + ?Sized>(input: &mut R) -> Result<Box<[T]>>

Deserialize array from the given input. Size of the array is serialized in VByte format.
source§

impl Serializer<u8> for VByte

source§

const CONST_SIZE: Option<usize> = _

Either size of each value in bytes (if each value occupies constant size) or None.
source§

fn size(_val: u8) -> usize

Returns number of bytes which write needs to serialize val.
source§

fn write<W: Write + ?Sized>(output: &mut W, val: u8) -> Result<()>

Serialize val to the given output.
source§

fn read<R: Read + ?Sized>(input: &mut R) -> Result<u8>

Deserialize value from the given input.
source§

fn write_all_values<W, InIter>(output: &mut W, values: InIter) -> Result<()>
where W: Write + ?Sized, InIter: IntoIterator<Item = T>,

Serialize all values into the given output.
source§

fn write_all<'a, W, InIter>(output: &mut W, values: InIter) -> Result<()>
where W: Write + ?Sized, InIter: IntoIterator<Item = &'a T>, T: 'a,

Serialize all values into the given output.
source§

fn array_content_size(array: &[T]) -> usize

Returns number of bytes occupied by serialized content of the array.
source§

fn array_size(array: &[T]) -> usize

Returns number of bytes which write_array needs to serialize array.
source§

fn write_array<W: Write + ?Sized>(output: &mut W, array: &[T]) -> Result<()>

Serialize array to the given input. Size of the array is serialized in VByte format.
source§

fn read_n<R: Read + ?Sized>(input: &mut R, n: usize) -> Result<Box<[T]>>

Deserialize n values from the given input.
source§

fn read_array<R: Read + ?Sized>(input: &mut R) -> Result<Box<[T]>>

Deserialize array from the given input. Size of the array is serialized in VByte format.
source§

impl Copy for VByte

Auto Trait Implementations§

§

impl RefUnwindSafe for VByte

§

impl Send for VByte

§

impl Sync for VByte

§

impl Unpin for VByte

§

impl UnwindSafe for VByte

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<S> Serializer<usize> for S
where S: Serializer<u64>,

source§

const CONST_SIZE: Option<usize> = const CONST_SIZE: Option<usize> = S::CONST_SIZE;

Either size of each value in bytes (if each value occupies constant size) or None.
source§

fn size(val: usize) -> usize

Returns number of bytes which write needs to serialize val.
source§

fn write<W>(output: &mut W, val: usize) -> Result<(), Error>
where W: Write + ?Sized,

Serialize val to the given output.
source§

fn read<R>(input: &mut R) -> Result<usize, Error>
where R: Read + ?Sized,

Deserialize value from the given input.
source§

fn write_all_values<W, InIter>(output: &mut W, values: InIter) -> Result<()>
where W: Write + ?Sized, InIter: IntoIterator<Item = T>,

Serialize all values into the given output.
source§

fn write_all<'a, W, InIter>(output: &mut W, values: InIter) -> Result<()>
where W: Write + ?Sized, InIter: IntoIterator<Item = &'a T>, T: 'a,

Serialize all values into the given output.
source§

fn array_content_size(array: &[T]) -> usize

Returns number of bytes occupied by serialized content of the array.
source§

fn array_size(array: &[T]) -> usize

Returns number of bytes which write_array needs to serialize array.
source§

fn write_array<W: Write + ?Sized>(output: &mut W, array: &[T]) -> Result<()>

Serialize array to the given input. Size of the array is serialized in VByte format.
source§

fn read_n<R: Read + ?Sized>(input: &mut R, n: usize) -> Result<Box<[T]>>

Deserialize n values from the given input.
source§

fn read_array<R: Read + ?Sized>(input: &mut R) -> Result<Box<[T]>>

Deserialize array from the given input. Size of the array is serialized in VByte format.
source§

impl<T> ToOwned for T
where T: Clone,

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.