Trait binout::Serializer
source · pub trait Serializer<T: Copy>: Copy {
const CONST_SIZE: Option<usize> = None;
// Required methods
fn size(val: T) -> usize;
fn write<W: Write + ?Sized>(output: &mut W, val: T) -> Result<()>;
fn read<R: Read + ?Sized>(input: &mut R) -> Result<T>;
// Provided methods
fn write_all_values<W, InIter>(output: &mut W, values: InIter) -> Result<()>
where W: Write + ?Sized,
InIter: IntoIterator<Item = T> { ... }
fn write_all<'a, W, InIter>(output: &mut W, values: InIter) -> Result<()>
where W: Write + ?Sized,
InIter: IntoIterator<Item = &'a T>,
T: 'a { ... }
fn array_content_size(array: &[T]) -> usize { ... }
fn array_size(array: &[T]) -> usize { ... }
fn write_array<W: Write + ?Sized>(output: &mut W, array: &[T]) -> Result<()> { ... }
fn read_n<R: Read + ?Sized>(input: &mut R, n: usize) -> Result<Box<[T]>> { ... }
fn read_array<R: Read + ?Sized>(input: &mut R) -> Result<Box<[T]>> { ... }
}
Expand description
Trait implemented by each serializer for the following types:
u8
, u16
, u32
, u64
, usize
(which, for portability, is always serialized the same as u64
).
Provided Associated Constants§
sourceconst 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
.
Required Methods§
Provided Methods§
sourcefn 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
.
sourcefn 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
.
sourcefn array_content_size(array: &[T]) -> usize
fn array_content_size(array: &[T]) -> usize
Returns number of bytes occupied by serialized content of the array.
sourcefn array_size(array: &[T]) -> usize
fn array_size(array: &[T]) -> usize
Returns number of bytes which write_array
needs to serialize array
.
sourcefn write_array<W: Write + ?Sized>(output: &mut W, array: &[T]) -> Result<()>
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.
Object Safety§
This trait is not object safe.