pub trait EncodeExt: EncodeSize + Write {
// Provided methods
fn encode_with_pool_mut(&self, pool: &BufferPool) -> IoBufMut { ... }
fn encode_with_pool(&self, pool: &BufferPool) -> IoBufs { ... }
}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) -> IoBufs
fn encode_with_pool(&self, pool: &BufferPool) -> IoBufs
Encode into IoBufs using pool allocation.
Override Write::write_bufs to avoid copying large Bytes fields.
§Panics
Panics if EncodeSize::encode_inline_size underreports the number
of inline bytes written by Write::write_bufs, or if
EncodeSize::encode_size does not match the total bytes written.
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.