Skip to main content

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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

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<()>

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<()>

Implementors§

Source§

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

Encode an Adapter into bytes.

Decoder is in decoders::binary::adapters.

Source§

impl<W> ToBytes<W> for Export<'_>
where W: Write,

Encode an Export into bytes.

Decoder is in decoders::binary::exports.

Source§

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

Encode an Implementation into bytes.

Decoder is in decoders::binary::implementations.

Source§

impl<W> ToBytes<W> for Import<'_>
where W: Write,

Encode an Import into bytes.

Decoder is in decoders::binary::imports.

Source§

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

Encode an Instruction into bytes.

Decoder is decoders::binary::instruction.

Source§

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

Encode an InterfaceType into bytes.

Source§

impl<W> ToBytes<W> for Interfaces<'_>
where W: Write,

Encode an Interfaces into bytes.

Decoder is decoders::binary::parse.

Source§

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

Encode a RecordType into bytes.

Source§

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

Encode a Type into bytes.

Decoder is in decoders::binary::types.

Source§

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

Encode a TypeKind into bytes.