Trait Inlinable

Source
pub trait Inlinable {
    // Required methods
    fn read_inlined<R: Read>(reader: &mut R) -> Result<Self>
       where Self: Sized;
    fn write_inlined<W: Write>(&self, wtr: &mut W) -> Result<usize>;

    // Provided methods
    fn read_optional_inlined<R: Read>(reader: &mut R) -> Result<Option<Self>>
       where Self: Sized { ... }
    fn write_inlined_with<W: Write>(
        &self,
        wtr: &mut W,
        _opts: InlineOpts,
    ) -> Result<usize> { ... }
    fn inlined(&self) -> Vec<u8>  { ... }
    fn printable_inlined(&self) -> String { ... }
}
Expand description

If one struct could be serialized/flattened to bytes array, we call it inlinable.

Required Methods§

Source

fn read_inlined<R: Read>(reader: &mut R) -> Result<Self>
where Self: Sized,

Read inlined bytes into object.

Source

fn write_inlined<W: Write>(&self, wtr: &mut W) -> Result<usize>

Write inlined bytes to a writer.

Provided Methods§

Source

fn read_optional_inlined<R: Read>(reader: &mut R) -> Result<Option<Self>>
where Self: Sized,

Source

fn write_inlined_with<W: Write>( &self, wtr: &mut W, _opts: InlineOpts, ) -> Result<usize>

Write inlined bytes with specific options

Source

fn inlined(&self) -> Vec<u8>

Get inlined bytes as vector.

Source

fn printable_inlined(&self) -> String

Get inlined bytes as printable string, all the bytes will displayed with escaped ascii code.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§