pub trait SbeEncoder: Sized {
const TEMPLATE_ID: u16;
const SCHEMA_ID: u16;
const SCHEMA_VERSION: u16;
const BLOCK_LENGTH: u16;
// Required methods
fn wrap(buffer: &mut [u8], offset: usize) -> Self;
fn encoded_length(&self) -> usize;
// Provided method
fn create_header() -> MessageHeader { ... }
}Expand description
Trait for SBE message encoders.
Implementations wrap a mutable byte buffer and provide field setters that write directly to the buffer.
§Example
ⓘ
// Generated encoder usage
let mut buffer = [0u8; 256];
let mut encoder = NewOrderSingleEncoder::wrap(&mut buffer, 0);
encoder
.set_symbol(b"AAPL ")
.set_quantity(100)
.set_price_mantissa(15050)
.set_price_exponent(-2);
let len = encoder.encoded_length();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 final encoded length after all writes.
This includes the header and all written portions.
Provided Methods§
Sourcefn create_header() -> MessageHeader
fn create_header() -> MessageHeader
Creates the message header for this encoder.
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.