pub trait FromSbeReuse: FromSbe {
type Scratch;
// Required method
fn from_sbe_reuse(
bytes: &[u8],
scratch: &mut Self::Scratch,
) -> Result<Self, SbeDecodeError>;
}Expand description
Extension of FromSbe that reuses allocations between decodes.
Scalar messages decode without heap allocation, so they do not need this trait. Types with
growable internal buffers (for example [OrderBookDeltas] with its Vec<OrderBookDelta>)
implement it to let callers supply a pre-allocated scratch buffer and avoid per-message
allocation in hot paths.
Required Associated Types§
Required Methods§
Sourcefn from_sbe_reuse(
bytes: &[u8],
scratch: &mut Self::Scratch,
) -> Result<Self, SbeDecodeError>
fn from_sbe_reuse( bytes: &[u8], scratch: &mut Self::Scratch, ) -> Result<Self, SbeDecodeError>
Decodes a value from an SBE message buffer, reusing scratch’s allocation.
On success, ownership of the allocation moves from scratch into the returned value and
scratch is left in its empty state. To continue reusing the allocation, move the buffer
back from the returned value (for example scratch = std::mem::take(&mut result.deltas)).
§Errors
Returns an error if the header is invalid or the payload is malformed.
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.