ToBytes

Trait ToBytes 

Source
pub trait ToBytes<W>
where W: Write,
{ // Required method fn to_bytes(&self, writer: &mut W) -> Result<()>; }
Expand description

A trait for converting a value to bytes.

Required Methods§

Source

fn to_bytes(&self, writer: &mut W) -> Result<()>

Converts the given value into &[u8] in the given writer.

Implementations on Foreign Types§

Source§

impl<W> ToBytes<W> for &str
where W: Write,

Encode a str into bytes.

Decoder is decoders::binary::string.

Source§

fn to_bytes(&self, writer: &mut W) -> Result<()>

Source§

impl<W> ToBytes<W> for u8
where W: Write,

Encode a u8 into a byte (well, it’s already a byte!).

Source§

fn to_bytes(&self, writer: &mut W) -> Result<()>

Source§

impl<W> ToBytes<W> for u64
where W: Write,

Encode a u64 into bytes with a LEB128 representation.

Decoder is decoders::binary::uleb.

Source§

fn to_bytes(&self, writer: &mut W) -> Result<()>

Source§

impl<W> ToBytes<W> for String
where W: Write,

Encode a String into bytes.

Decoder is decoders::binary::string.

Source§

fn to_bytes(&self, writer: &mut W) -> Result<()>

Source§

impl<W, I> ToBytes<W> for Vec<I>
where W: Write, I: ToBytes<W>,

Encode a vector into bytes.

Decoder is decoders::binary::list.

Source§

fn to_bytes(&self, writer: &mut W) -> Result<()>

Implementors§