pub trait SbeDecoder<'a>: Sized {
const TEMPLATE_ID: u16;
const SCHEMA_ID: u16;
const SCHEMA_VERSION: u16;
const BLOCK_LENGTH: u16;
// Required methods
fn wrap(buffer: &'a [u8], offset: usize, acting_version: u16) -> Self;
fn encoded_length(&self) -> usize;
// Provided methods
fn validate_header(header: &MessageHeader) -> Result<(), DecodeError> { ... }
fn decode(buffer: &'a [u8]) -> Result<Self, DecodeError> { ... }
}Expand description
Trait for zero-copy SBE message decoders.
Implementations wrap a byte buffer and provide field accessors that read directly from the buffer without copying data.
§Type Parameters
'a- Lifetime of the underlying buffer
§Example
ⓘ
// Generated decoder usage
let decoder = NewOrderSingleDecoder::wrap(&buffer, 0, SCHEMA_VERSION);
let symbol = decoder.symbol();
let quantity = decoder.quantity();Required Associated Constants§
Sourceconst TEMPLATE_ID: u16
const TEMPLATE_ID: u16
Schema template ID for this message type.
Sourceconst SCHEMA_VERSION: u16
const SCHEMA_VERSION: u16
Schema version.
Sourceconst BLOCK_LENGTH: u16
const BLOCK_LENGTH: u16
Block length (fixed portion size in bytes).
Required Methods§
Sourcefn encoded_length(&self) -> usize
fn encoded_length(&self) -> usize
Returns the encoded length of the message in bytes.
This includes the header and all fixed/variable portions.
Provided Methods§
Sourcefn validate_header(header: &MessageHeader) -> Result<(), DecodeError>
fn validate_header(header: &MessageHeader) -> Result<(), DecodeError>
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.