Skip to main content

EncodeExt

Trait EncodeExt 

Source
pub trait EncodeExt: EncodeSize + Write {
    // Provided methods
    fn encode_with_pool_mut(&self, pool: &BufferPool) -> IoBufMut { ... }
    fn encode_with_pool(&self, pool: &BufferPool) -> IoBuf { ... }
}
Expand description

Extension trait for encoding values into pooled I/O buffers.

This is useful for hot paths that need to avoid frequent heap allocations when serializing values that implement Write and EncodeSize.

Provided Methods§

Source

fn encode_with_pool_mut(&self, pool: &BufferPool) -> IoBufMut

Encode this value into an IoBufMut allocated from pool.

§Panics

Panics if EncodeSize::encode_size does not match the number of bytes written by Write::write.

Source

fn encode_with_pool(&self, pool: &BufferPool) -> IoBuf

Encode this value into an immutable IoBuf allocated from pool.

§Panics

Panics if EncodeSize::encode_size does not match the number of bytes written by Write::write.

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§