Skip to main content

ironfix_example/
lib.rs

1/******************************************************************************
2   Author: Joaquín Béjar García
3   Email: jb@taunais.com
4   Date: 27/1/26
5******************************************************************************/
6
7#![allow(non_snake_case)]
8
9//! # IronFix
10//!
11//! A high-performance FIX/FAST protocol engine for Rust.
12//!
13//! IronFix provides a complete implementation of the FIX protocol with support for
14//! all versions from FIX 4.0 through FIX 5.0 SP2, as well as FAST-encoded market data.
15//!
16//! ## Features
17//!
18//! - **Zero-copy parsing**: Field values reference the original buffer
19//! - **SIMD-accelerated**: Uses `memchr` for fast delimiter search
20//! - **Type-safe**: Compile-time checked session states and message types
21//! - **Async support**: Built on Tokio for high-performance networking
22//! - **Flexible**: Supports both sync and async operation modes
23//!
24//! ## Quick Start
25//!
26//! ```rust,ignore
27//! use ironfix_example::prelude::*;
28//!
29//! // Create an engine with your application handler
30//! let engine = EngineBuilder::new()
31//!     .with_application(MyApplication)
32//!     .add_session(SessionConfig::new(
33//!         CompId::new("SENDER").unwrap(),
34//!         CompId::new("TARGET").unwrap(),
35//!         "FIX.4.4",
36//!     ))
37//!     .build();
38//! ```
39//!
40//! ## Crate Organization
41//!
42//! - [`core`]: Fundamental types, traits, and error definitions
43//! - [`dictionary`]: FIX specification parsing and dictionary management
44//! - [`tagvalue`]: Zero-copy tag=value encoding and decoding
45//! - [`session`]: Session layer protocol implementation
46//! - [`store`]: Message persistence and storage
47//! - [`transport`]: Network transport layer
48//! - [`fast`]: FAST protocol encoding and decoding
49//! - [`engine`]: High-level engine facade
50
51pub mod core {
52    //! Core types, traits, and error definitions.
53    pub use ironfix_core::*;
54}
55
56pub mod dictionary {
57    //! FIX specification parsing and dictionary management.
58    pub use ironfix_dictionary::*;
59}
60
61pub mod tagvalue {
62    //! Zero-copy tag=value encoding and decoding.
63    pub use ironfix_tagvalue::*;
64}
65
66pub mod session {
67    //! Session layer protocol implementation.
68    pub use ironfix_session::*;
69}
70
71pub mod store {
72    //! Message persistence and storage.
73    pub use ironfix_store::*;
74}
75
76pub mod transport {
77    //! Network transport layer.
78    pub use ironfix_transport::*;
79}
80
81pub mod fast {
82    //! FAST protocol encoding and decoding.
83    pub use ironfix_fast::*;
84}
85
86pub mod engine {
87    //! High-level engine facade.
88    pub use ironfix_engine::*;
89}
90
91/// Prelude module for convenient imports.
92pub mod prelude {
93    // Core types
94    pub use ironfix_core::{
95        CompId, DecodeError, EncodeError, FieldRef, FieldTag, FieldValue, FixError, FixField,
96        FixMessage, MsgType, OwnedMessage, RawMessage, Result, SeqNum, SessionError, Side,
97        StoreError, Timestamp,
98    };
99
100    // Dictionary
101    pub use ironfix_dictionary::{Dictionary, FieldDef, FieldType, MessageDef, Version};
102
103    // Tag-value encoding
104    pub use ironfix_tagvalue::{Decoder, Encoder, calculate_checksum};
105
106    // Session
107    pub use ironfix_session::{
108        Active, Connecting, Disconnected, HeartbeatManager, LogonSent, LogoutPending, Resending,
109        SequenceManager, SessionConfig, SessionState,
110    };
111
112    // Store
113    pub use ironfix_store::{MemoryStore, MessageStore};
114
115    // Transport
116    pub use ironfix_transport::{CodecError, FixCodec};
117
118    // FAST
119    pub use ironfix_fast::{FastDecoder, FastEncoder, FastError, PresenceMap};
120
121    // Engine
122    pub use ironfix_engine::{Application, EngineBuilder};
123}
124
125#[cfg(test)]
126mod tests {
127    use super::prelude::*;
128
129    #[test]
130    fn test_prelude_imports() {
131        // Verify that prelude imports work
132        let _seq = SeqNum::new(1);
133        let _ts = Timestamp::now();
134        let _side = Side::Buy;
135    }
136
137    #[test]
138    fn test_version() {
139        let version = Version::Fix44;
140        assert_eq!(version.begin_string(), "FIX.4.4");
141    }
142}