Expand description
The zero_copy module contains all the zero-copy-related data structures used in the system. Zero-copy market data structures for ultra-fast binary parsing
This module provides zerocopy-enabled structures for direct memory mapping of binary market data from exchanges, eliminating parsing overhead.
§Bytemuck Usage Strategy
We use a hybrid approach with bytemuck for maximum safety:
-
Non-generic structs (ZeroCopyPriceLevel, ZeroCopyTrade, MessageHeader):
- Use bytemuck’s Pod and Zeroable derives for safe zero-copy operations
- All methods use bytemuck’s safe APIs (bytes_of, try_from_bytes)
-
Generic structs (ZeroCopyOrderBookUpdate
): - Cannot derive Pod/Zeroable due to const generic limitations
- Bytemuck doesn’t support arrays [T; N] with generic N
- Maintain minimal unsafe code with comprehensive safety documentation
- Use parse_message_generic() instead of parse_message()
This approach maximizes safety while maintaining the flexibility of const generics for compile-time configurable buffer sizes.
Re-exports§
pub use ZeroCopyOrderBookUpdate10 as DefaultZeroCopyOrderBookUpdate;
Structs§
- Message
Header - Zero-copy message header for length-prefixed protocols
- Zero
Copy Order Book Update - Zero-copy order book update with const generic array sizing
- Zero
Copy Price Level - Zero-copy price level structure
- Zero
Copy Trade - Zero-copy trade message
Functions§
- parse_
message - Parse a message from a buffer with proper alignment checks
- parse_
message_ generic - Parse a message from a buffer for types that can’t implement Pod
- parse_
message_ mut - Parse a mutable message from a buffer with proper alignment checks
Type Aliases§
- Zero
Copy Order Book Update5 - Type alias for a zero-copy order book update with 5 levels per side.
- Zero
Copy Order Book Update10 - Type alias for a zero-copy order book update with 10 levels per side.
- Zero
Copy Order Book Update20 - Type alias for a zero-copy order book update with 20 levels per side.