fefix/lib.rs
1//! A Financial Information eXchange
2//! ([FIX](https://www.fixtrading.org/standards/)) protocol implementation in Rust.
3//!
4//! FerrumFIX is a collection of reusable components to produce and consume
5//! FIX-compliant data. It is *not* a FIX engine, although you can very easily
6//! build one with FerrumFIX. FerrumFIX is intended to be:
7//!
8//! - **Comprehensive**. Most standards adopted by the FIX Community are
9//! either available or planned, from session layers to encodings and
10//! dictionary-related logic.
11//! - **Foundational**. FerrumFIX is foundational in the sense that it exposes a
12//! large amount of primitives in its public interface, so that users can
13//! easily build upon them to implement custom solutions tailored for their
14//! needs. You'll often find that there are many ways of doing the same thing.
15//! It's up to you to choose whatever works best.
16//! - **Unopinionated**. We try to provide good defaults, but you can discard
17//! them entirely and provide your own should you choose to do so.
18//! Customization is mostly done via Rust traits, which allows for inlining and
19//! maintains great performance.
20//! - **Fast**. Everything is planned around zero-copy and zero-allocations in
21//! the hot paths.
22//!
23//! Please check out the [README](https://github.com/neysofu/fefix/) for more
24//! general information regarding FerrumFIX.
25//!
26//! # Cargo features
27//!
28//! FerrumFIX puts a lot of functionality behind optional features in order to
29//! optimize compilation times. The following features are available:
30//!
31//! ### `fix40`, `fix41`, `fix42`, `fix43`, `fix44`, `fix50`, `fix50sp1`, `fix50sp2`, `fixt11`
32//!
33//! Version-specific FIX utilities. See the modules within [`definitions`] and
34//! the similarly named [`Dictionary`] methods.
35//!
36//! ### `utils-chrono`, `utils-decimal`, `utils-rust-decimal`
37//!
38//! [`FixValue`] implementations for third-party crates and type conversions.
39//!
40//! ### `utils-slog`
41//!
42//! Logging of [`tagvalue::Message`]s.
43//!
44//! ### `utils-bytes`, `utils-tokio`
45//!
46//! FIX decoders and encoders that integrate nicely with the Tokio ecosystem.
47//!
48//! ### `json-encoding`
49//!
50//! Decode and encode FIX messages with JSON.
51//!
52//! ### `codegen`
53//!
54//! This feature it intended to be used within Cargo's `[build-dependencies]`, like this:
55//!
56//! ```toml
57//! fefix = { version = "0.1", features = ["codegen"] }
58//! ```
59//!
60//! `codegen` allows you to generate Rust files with lots of FIX version
61//! -specific constants, types, and documentation. This is not mandatory by any
62//! means and you can decide to simply use [`Dictionary`], which provides
63//! dynamic access to mostly the same information, but you'll lose on
64//! performance, type safety, and quality of life. There's no reason not to use
65//! `codegen` if your use case allows it (it likely does!).
66//!
67//! # FAQ
68//!
69//! - **Q.** I simply want to read FIX messages. Where do I start?
70//! **A.** Use [`fefix::tagvalue::Decoder`](crate::tagvalue::Decoder) and
71//! [`fefix::tagvalue::DecoderBuffered`](crate::tagvalue::DecoderBuffered).
72//! The former is for individual messages, the latter is for streams.
73//!
74//! - **Q.** What about `serde` integration?
75//! **A.** FIX semantics don't map well to `serde` and there are subtle
76//! performance implications. It's not a good idea.
77//!
78//! # External resources
79//!
80//! - [`https://fixtrading.org/standards`](https://fixtrading.org/standards).
81//! - [`https://fiximate.fixtrading.org`](https://fiximate.fixtrading.org).
82//! - [`https://github.com/FIXTradingCommunity`](https://github.com/FIXTradingCommunity).
83//! - [`https://forum.fixtrading.org`](https://forum.fixtrading.org).
84
85#![doc(html_root_url = "https://docs.rs/fefix/")]
86#![warn(missing_docs)]
87#![deny(
88 //unused FIXME,
89 missing_debug_implementations,
90 unsafe_op_in_unsafe_fn,
91 rustdoc::broken_intra_doc_links,
92 //missing_docs FIXME,
93 unconditional_recursion,
94 unstable_name_collisions,
95 clippy::useless_conversion,
96 clippy::missing_panics_docs,
97 clippy::mixed_case_hex_literals,
98 clippy::needless_bool,
99 clippy::needless_lifetimes,
100 rustdoc::invalid_rust_codeblocks
101)]
102// Only enables the `doc_cfg` feature when its feature is defined.
103#![cfg_attr(doc_cfg, feature(doc_cfg))]
104
105mod buffer;
106mod fefix_core;
107mod fix_value;
108mod utils;
109
110pub mod definitions;
111pub mod fix_values;
112pub mod prelude;
113pub mod session;
114pub mod tagvalue;
115
116#[cfg(feature = "json-encoding")]
117#[cfg_attr(doc_cfg, doc(cfg(feature = "json-encoding")))]
118pub mod json;
119#[cfg(feature = "codegen")]
120#[cfg_attr(doc_cfg, doc(cfg(feature = "codegen")))]
121pub use fefix_core::codegen;
122
123pub use buffer::Buffer;
124pub use dict::Dictionary;
125pub use fefix_core::dict;
126pub use fefix_core::TagU16;
127pub use fix_value::FixValue;
128
129// We don't show derive macros to pollute the docs.
130#[doc(hidden)]
131pub use fefix_derive::FixValue;
132
133/// Allows to get mutable and immutable references to configuration options.
134pub trait GetConfig {
135 /// The configuration options type.
136 type Config;
137
138 /// Returns an immutable reference to the configuration options used by
139 /// `self`.
140 fn config(&self) -> &Self::Config;
141
142 /// Returns a mutable reference to the configuration options used by
143 /// `self`.
144 fn config_mut(&mut self) -> &mut Self::Config;
145}