Skip to main content

Encode

Trait Encode 

Source
pub trait Encode<V>: Sized {
    // Required method
    fn encode<W: BufMut>(
        &self,
        w: &mut W,
        version: V,
    ) -> Result<(), EncodeError>;

    // Provided method
    fn encode_bytes(&self, v: V) -> Result<Bytes, EncodeError> { ... }
}
Expand description

Write the value to the buffer using the given version.

Required Methods§

Source

fn encode<W: BufMut>(&self, w: &mut W, version: V) -> Result<(), EncodeError>

Encode the value to the given writer.

Provided Methods§

Source

fn encode_bytes(&self, v: V) -> Result<Bytes, EncodeError>

Encode the value into a Bytes buffer.

NOTE: This will allocate.

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.

Implementations on Foreign Types§

Source§

impl<T: Encode<V>, V> Encode<V> for Arc<T>

Source§

fn encode<W: BufMut>(&self, w: &mut W, version: V) -> Result<(), EncodeError>

Source§

impl<V> Encode<V> for bool

Source§

fn encode<W: BufMut>(&self, w: &mut W, _: V) -> Result<(), EncodeError>

Source§

impl<V> Encode<V> for i8

Source§

fn encode<W: BufMut>(&self, w: &mut W, _: V) -> Result<(), EncodeError>

Source§

impl<V> Encode<V> for u8

Source§

fn encode<W: BufMut>(&self, w: &mut W, _: V) -> Result<(), EncodeError>

Source§

impl<V> Encode<V> for u16

Source§

fn encode<W: BufMut>(&self, w: &mut W, _: V) -> Result<(), EncodeError>

Source§

impl<V: Copy> Encode<V> for &str
where usize: Encode<V>,

Source§

fn encode<W: BufMut>(&self, w: &mut W, version: V) -> Result<(), EncodeError>

Source§

impl<V: Copy> Encode<V> for Cow<'_, str>
where usize: Encode<V>,

Source§

fn encode<W: BufMut>(&self, w: &mut W, version: V) -> Result<(), EncodeError>

Source§

impl<V: Copy> Encode<V> for Option<u64>
where u64: Encode<V>,

Source§

fn encode<W: BufMut>(&self, w: &mut W, version: V) -> Result<(), EncodeError>

Source§

impl<V: Copy> Encode<V> for u32
where VarInt: Encode<V>,

Source§

fn encode<W: BufMut>(&self, w: &mut W, version: V) -> Result<(), EncodeError>

Source§

impl<V: Copy> Encode<V> for u64
where VarInt: Encode<V>,

Source§

fn encode<W: BufMut>(&self, w: &mut W, version: V) -> Result<(), EncodeError>

Source§

impl<V: Copy> Encode<V> for usize
where VarInt: Encode<V>,

Source§

fn encode<W: BufMut>(&self, w: &mut W, version: V) -> Result<(), EncodeError>

Source§

impl<V: Copy> Encode<V> for String
where usize: Encode<V>,

Source§

fn encode<W: BufMut>(&self, w: &mut W, version: V) -> Result<(), EncodeError>

Source§

impl<V: Copy> Encode<V> for Vec<u8>
where usize: Encode<V>,

Source§

fn encode<W: BufMut>(&self, w: &mut W, version: V) -> Result<(), EncodeError>

Source§

impl<V: Copy> Encode<V> for Duration
where VarInt: Encode<V>,

Source§

fn encode<W: BufMut>(&self, w: &mut W, version: V) -> Result<(), EncodeError>

Source§

impl<V: Copy> Encode<V> for Bytes
where usize: Encode<V>,

Source§

fn encode<W: BufMut>(&self, w: &mut W, version: V) -> Result<(), EncodeError>

Source§

impl<V: Copy, T: Encode<V>> Encode<V> for &[T]
where usize: Encode<V>,

Source§

fn encode<W: BufMut>(&self, w: &mut W, version: V) -> Result<(), EncodeError>

Implementors§

Source§

impl Encode<Version> for moq_lite::Version

Source§

impl Encode<Version> for VarInt

Source§

impl<V: Copy> Encode<V> for Path<'_>
where for<'a> &'a str: Encode<V>,

Source§

impl<V: Copy> Encode<V> for moq_lite::coding::Version
where u64: Encode<V>,

Source§

impl<V: Copy> Encode<V> for Versions
where u64: Encode<V>,

Source§

impl<const SCALE: u64> Encode<Version> for Timescale<SCALE>