Module stream

Module stream 

Source
Expand description

Binance SBE market data stream decoders (schema 1:0).

These decoders are hand-written for the 4 market data stream message types:

All decoders return Result<T, StreamDecodeError> to safely handle malformed or truncated network data without panicking.

Modules§

template_id
Message template IDs for stream events.

Structs§

BestBidAskStreamEvent
Best bid/ask stream event.
DepthDiffStreamEvent
Depth diff stream event (incremental order book updates).
DepthSnapshotStreamEvent
Depth snapshot stream event (top N levels of order book).
GroupSize16Encoding
Group size 16 encoding (4 bytes: u16 block_length + u16 num_in_group).
GroupSizeEncoding
Group size encoding (6 bytes: u16 block_length + u32 num_in_group).
MessageHeader
SBE message header (8 bytes).
PriceLevel
Price/quantity level in order book.
Trade
Individual trade within a trades stream event.
TradesStreamEvent
Trades stream event (may contain multiple trades).

Enums§

StreamDecodeError
Stream decode error.

Constants§

MAX_GROUP_SIZE
Maximum allowed group size to prevent OOM from malicious payloads. Binance depth streams typically have at most 5000 levels.
STREAM_SCHEMA_ID
Stream schema ID.
STREAM_SCHEMA_VERSION
Stream schema version.

Functions§

decode_var_string8
Decode a varString8 (1-byte length prefix + UTF-8 data).
mantissa_to_f64
Convert mantissa and exponent to f64.