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§
Sourcefn encode_with_pool_mut(&self, pool: &BufferPool) -> IoBufMut
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.
Sourcefn encode_with_pool(&self, pool: &BufferPool) -> IoBuf
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.