Crates.io | fix44-forge-helpers |
lib.rs | fix44-forge-helpers |
version | 0.1.3 |
created_at | 2025-08-20 18:08:56.627115+00 |
updated_at | 2025-08-23 05:06:27.562545+00 |
description | Zero-allocation, high-performance helper functions for FIX 4.4 protocol parsing and serialization |
homepage | https://github.com/raul-gherman/fix44-forge |
repository | https://github.com/raul-gherman/fix44-forge-helpers |
max_upload_size | |
id | 1803768 |
size | 158,052 |
High-performance helper functions for FIX 4.4 protocol parsing and serialization.
This crate provides zero-allocation, minimal-branching functions for reading and writing FIX protocol data types. It's designed for hot-path performance in financial applications where every nanosecond counts.
Unix/Linux Only - This crate is designed exclusively for Unix-like systems and will NOT compile or run on Windows.
The crate uses platform-specific optimizations including:
libc::clock_gettime
for high-precision timestampsSupported platforms:
If you need Windows compatibility, please consider crates in rust ecosystem that perform well under it - this one is not and will not be one of them.
Add this to your Cargo.toml
:
[dependencies]
fix44-forge-helpers = "0.1"
Platform Requirements:
use fix44_forge_helpers::*;
// Parse integers
let value = read_u32(b"12345");
assert_eq!(value, 12345);
// Parse floats
let price = read_f64(b"123.45");
assert_eq!(price, 123.45);
// Parse booleans (FIX Y/N format)
let flag = read_bool(b"Y");
assert_eq!(flag, true);
// Parse strings
let symbol = read_str(b"MSFT");
assert_eq!(symbol, "MSFT");
use fix44_forge_helpers::*;
let mut buffer = [0u8; 100];
let mut pos = 0;
// Write integers
pos += write_u32(12345, &mut buffer, pos);
assert_eq!(&buffer[..pos], b"12345");
// Write floats with automatic precision
pos = 0;
pos += write_f64(123.456789, &mut buffer, pos);
assert_eq!(&buffer[..pos], b"123.456789");
// Write complete FIX fields
pos = 0;
pos += write_tag_and_u32(&mut buffer, pos, b"34=", 123);
assert_eq!(&buffer[..pos], b"34=123\x01");
use fix44_forge_helpers::*;
let mut buffer = [0u8; 100];
// Generate unique ClOrdID
let written = write_tag_and_ClOrdID(&mut buffer, 0, b"11=");
// Result: b"11=ABCDEFGHIJKLM\x01" (13-char base36 ID)
// Write current timestamp
let written = write_tag_and_current_timestamp(&mut buffer, 0, b"52=");
// Result: b"52=20240101-12:34:56.789\x01"
unsafe
operations for maximum speed (caller must ensure buffer capacity)Run benchmarks with:
cargo bench
Typical performance on modern hardware:
This crate uses unsafe
code extensively for performance. When using writing functions:
Type | Maximum Bytes |
---|---|
u16 |
5 |
u32 |
10 |
u64 |
20 |
u128 |
39 |
i16 |
6 (includes sign) |
i32 |
11 (includes sign) |
i64 |
20 (includes sign) |
f32 |
~15 (sign + integer + '.' + 6 fractional) |
f64 |
~25 (sign + integer + '.' + 15 fractional) |
Timestamp | 21 (YYYYMMDD-HH:MM:SS.mmm) |
ClOrdID | 13 (base36 encoding) |
Generates unique 13-character base36 identifiers suitable for FIX ClOrdID fields:
Optimized UTC timestamp generation in FIX format (YYYYMMDD-HH:MM:SS.mmm):
libc::clock_gettime
for speed (Unix-only)Use the ReadError
type for structured validation when needed:
use fix44_forge_helpers::ReadError;
let error = ReadError::InvalidValue {
name: "Price",
tag: 44,
msg: "Non-numeric character found",
};
Run the test suite:
# All tests
cargo test
# Just this crate
cargo test -p fix44-forge-helpers
# With optimizations (for performance validation)
cargo test --release
The test suite includes:
This crate is intentionally Unix-only. It uses:
libc::clock_gettime
for nanosecond-precision timestamps (not available on Windows)Alternatives for Windows users:
No. Adding Windows support would require:
clock_gettime
)This crate prioritizes absolute performance over platform compatibility.
cargo test
cargo bench
Licensed under either of
at your option.