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 Serializer<u16> for VByte
impl Serializer<u16> for VByte
source§fn write<W: Write + ?Sized>(output: &mut W, val: u16) -> Result<()>
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>
fn read<R: Read + ?Sized>(input: &mut R) -> Result<u16>
Deserialize value from the given
input
.source§const CONST_SIZE: Option<usize> = None
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<()>
fn write_all_values<W, InIter>(output: &mut W, values: InIter) -> Result<()>
Serialize all
values
into the given output
.source§fn write_all<'a, W, InIter>(output: &mut W, values: InIter) -> Result<()>
fn write_all<'a, W, InIter>(output: &mut W, values: InIter) -> Result<()>
Serialize all
values
into the given output
.source§fn array_content_size(array: &[T]) -> usize
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
fn array_size(array: &[T]) -> usize
Returns number of bytes which
write_array
needs to serialize array
.source§impl Serializer<u32> for VByte
impl Serializer<u32> for VByte
source§fn write<W: Write + ?Sized>(output: &mut W, val: u32) -> Result<()>
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>
fn read<R: Read + ?Sized>(input: &mut R) -> Result<u32>
Deserialize value from the given
input
.source§const CONST_SIZE: Option<usize> = None
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<()>
fn write_all_values<W, InIter>(output: &mut W, values: InIter) -> Result<()>
Serialize all
values
into the given output
.source§fn write_all<'a, W, InIter>(output: &mut W, values: InIter) -> Result<()>
fn write_all<'a, W, InIter>(output: &mut W, values: InIter) -> Result<()>
Serialize all
values
into the given output
.source§fn array_content_size(array: &[T]) -> usize
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
fn array_size(array: &[T]) -> usize
Returns number of bytes which
write_array
needs to serialize array
.source§impl Serializer<u64> for VByte
impl Serializer<u64> for VByte
source§fn write<W: Write + ?Sized>(output: &mut W, val: u64) -> Result<()>
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>
fn read<R: Read + ?Sized>(input: &mut R) -> Result<u64>
Deserialize value from the given
input
.source§const CONST_SIZE: Option<usize> = None
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<()>
fn write_all_values<W, InIter>(output: &mut W, values: InIter) -> Result<()>
Serialize all
values
into the given output
.source§fn write_all<'a, W, InIter>(output: &mut W, values: InIter) -> Result<()>
fn write_all<'a, W, InIter>(output: &mut W, values: InIter) -> Result<()>
Serialize all
values
into the given output
.source§fn array_content_size(array: &[T]) -> usize
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
fn array_size(array: &[T]) -> usize
Returns number of bytes which
write_array
needs to serialize array
.source§impl Serializer<u8> for VByte
impl Serializer<u8> for VByte
source§const CONST_SIZE: Option<usize> = _
const CONST_SIZE: Option<usize> = _
Either size of each value in bytes (if each value occupies constant size) or
None
.source§fn write<W: Write + ?Sized>(output: &mut W, val: u8) -> Result<()>
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>
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<()>
fn write_all_values<W, InIter>(output: &mut W, values: InIter) -> Result<()>
Serialize all
values
into the given output
.source§fn write_all<'a, W, InIter>(output: &mut W, values: InIter) -> Result<()>
fn write_all<'a, W, InIter>(output: &mut W, values: InIter) -> Result<()>
Serialize all
values
into the given output
.source§fn array_content_size(array: &[T]) -> usize
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
fn array_size(array: &[T]) -> usize
Returns number of bytes which
write_array
needs to serialize array
.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> 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
source§impl<S> Serializer<usize> for Swhere
S: Serializer<u64>,
impl<S> Serializer<usize> for Swhere
S: Serializer<u64>,
source§const CONST_SIZE: Option<usize> = const CONST_SIZE: Option<usize> = S::CONST_SIZE;
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 write<W>(output: &mut W, val: usize) -> Result<(), Error>
fn write<W>(output: &mut W, val: usize) -> Result<(), Error>
Serialize
val
to the given output
.source§fn write_all_values<W, InIter>(output: &mut W, values: InIter) -> Result<()>
fn write_all_values<W, InIter>(output: &mut W, values: InIter) -> Result<()>
Serialize all
values
into the given output
.source§fn write_all<'a, W, InIter>(output: &mut W, values: InIter) -> Result<()>
fn write_all<'a, W, InIter>(output: &mut W, values: InIter) -> Result<()>
Serialize all
values
into the given output
.source§fn array_content_size(array: &[T]) -> usize
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
fn array_size(array: &[T]) -> usize
Returns number of bytes which
write_array
needs to serialize array
.