Skip to main content

Module ws_decoder

Module ws_decoder 

Source
Expand description

Shared WebSocket frame decoding helpers.

Every exchange’s WS handler needs to (a) handle both single-object and array-of-objects frames, (b) skip the slow serde_json::Value + from_value(value.clone()) double-parse pattern that existed before. decode_frame centralises both.

When the simd-json feature is enabled, large payloads route through simd-json’s SIMD tokenizer (~15-20% faster on mid-to-large WS frames); small payloads stay on serde_json, where the SIMD startup cost would otherwise dominate the parse.

Enums§

WsFrame
A parsed WebSocket frame — either a single object or an array-of-objects.

Functions§

decode_frame
Decode text into a WsFrame<T> with a single pass of whatever JSON parser is fastest for its size.
decode_value
Parse text into a serde_json::Value using the same size-based simd switching as decode_frame. For exchanges (e.g. kalshi) that dispatch on a field inside a loosely typed Value rather than deserialising into a bespoke RawWsMessage struct.