Module const_fn_candidates

Source
Expand description

Const fn utility functions for compile-time evaluation

This module contains simple, pure functions that can be evaluated at compile time. These utilities provide performance benefits by computing values during compilation rather than at runtime.

Functionsยง

array_len
Array and slice utilities Get the length of a static array at compile time
bps_to_percent
Calculate percentage from basis points
buffer_size_power_of_two
Buffer sizing utilities Calculate buffer size rounded up to next power of 2
bytes_to_kb
Type conversions Convert bytes to kilobytes (1024 bytes = 1 KB)
bytes_to_mb
Convert bytes to megabytes (1024 * 1024 bytes = 1 MB)
cache_aligned_size
Calculate cache-line aligned size (64 bytes)
const_max_i64
Calculate the maximum of two i64 values at compile time
const_max_u64
Mathematical constants and operations Calculate the maximum of two u64 values at compile time
const_min_i64
Calculate the minimum of two i64 values at compile time
const_min_u64
Calculate the minimum of two u64 values at compile time
exchange_default_websocket_port
Get default WebSocket port for exchange
exchange_max_api_key_length
Calculate maximum API key length for exchange
exchange_max_signature_length
Authentication and security utilities Calculate maximum signature length for exchange authentication
exchange_max_websocket_message_size
Calculate maximum WebSocket message size for exchange
exchange_optimal_batch_size
Performance and optimization utilities Calculate optimal batch size for exchange message processing
exchange_reconnection_delay_ms
Calculate reconnection delay for exchange (exponential backoff)
exchange_requires_custom_ping
Check if exchange requires custom ping message format
exchange_requires_passphrase
Check if exchange requires passphrase for authentication
exchange_supports_websocket_compression
WebSocket and networking utilities Check if an exchange supports WebSocket compression at compile time
exchange_websocket_ping_interval_ms
Calculate WebSocket ping interval in milliseconds for exchange
is_power_of_two
Check if a u64 value is a power of 2 at compile time
is_valid_index
Check if an index is valid for a given length at compile time
is_valid_tick_price
Check if price is within tick size boundaries
kb_to_bytes
Convert kilobytes to bytes
mb_to_bytes
Convert megabytes to bytes
micros_to_nanos
Network and latency utilities Convert microseconds to nanoseconds
mid_price
Calculate mid price from bid and ask
millis_to_nanos
Convert milliseconds to nanoseconds
nanos_to_micros
Convert nanoseconds to microseconds
nanos_to_millis
Convert nanoseconds to milliseconds
nanos_to_seconds
Convert nanoseconds to seconds
next_power_of_two
Calculate the next power of 2 for a u64 value at compile time
optimal_simd_chunks
Calculate optimal SIMD chunk size for given element count and max chunks
orderbook_depth_for_memory
HFT-specific utilities Calculate order book depth for given memory budget (bytes)
percent_to_bps
Trading-specific utilities Calculate basis points (bps) from a percentage (1% = 100 bps)
pool_capacity_for_throughput
Calculate pool capacity based on expected throughput
price_diff_bps
HFT-specific financial calculations Calculate basis points difference between two prices
round_to_tick
Round price to nearest tick
seconds_to_nanos
Convert seconds to nanoseconds
simd_aligned_size
Calculate SIMD-aligned buffer size (multiple of 4 for f64x4)
simd_f64x4_buffer_size
Calculate total SIMD buffer size for f64x4 operations
simd_f64x4_chunks
SIMD and vectorization utilities Calculate number of SIMD chunks needed for f64x4 operations
spread_bps
Calculate spread in basis points
tick_count
Calculate tick count between two prices
tick_size_to_decimals
Calculate the number of decimal places for a given tick size For example, tick size 0.01 has 2 decimal places
websocket_max_message_size
Calculate maximum message size for WebSocket buffer