|
| 1 | +# easyfix-core |
| 2 | + |
| 3 | +Core types and traits for the [easyfix](https://github.com/ldanko/easyfix) FIX |
| 4 | +engine. |
| 5 | + |
| 6 | +This crate defines the contract between the session layer (`easyfix-session`) |
| 7 | +and message implementations — whether generated from XML by `easyfix-messages` |
| 8 | +or hand-written for custom use cases. |
| 9 | + |
| 10 | +## What's inside |
| 11 | + |
| 12 | +### Basic types |
| 13 | + |
| 14 | +Foundational FIX types used across the engine: |
| 15 | + |
| 16 | +- String types: `FixStr` (borrowed), `FixString` (owned) |
| 17 | +- Numeric types: `Int`, `Float` (`Decimal`), `SeqNum`, `TagNum` |
| 18 | +- Temporal types: `UtcTimestamp`, `UtcTimeOnly`, `UtcDateOnly`, `TzTimestamp`, |
| 19 | + `TzTimeOnly` (re-exported from `chrono`) |
| 20 | +- Other: `Boolean`, `Char`, `Country`, `Currency` |
| 21 | +- Field newtypes: `MsgTypeField`, `SessionStatusField`, |
| 22 | + `SessionRejectReasonField` — opaque wrappers used in base messages and |
| 23 | + session APIs |
| 24 | + |
| 25 | +### Base messages |
| 26 | + |
| 27 | +Minimal typed structures containing only the fields the session layer needs: |
| 28 | + |
| 29 | +- `HeaderBase` — routing and sequencing fields (BeginString, SenderCompID, |
| 30 | + TargetCompID, MsgSeqNum, SendingTime, etc.) |
| 31 | +- `AdminBase` — enum over the 7 admin message types (Logon, Logout, Heartbeat, |
| 32 | + TestRequest, ResendRequest, SequenceReset, Reject) |
| 33 | +- Base enumerations: `MsgTypeBase`, `SessionStatusBase`, |
| 34 | + `SessionRejectReasonBase`, `EncryptMethodBase` |
| 35 | + |
| 36 | +Base messages use `Cow<FixStr>` for string fields — zero-copy borrowing on |
| 37 | +incoming messages, owned construction on outgoing. |
| 38 | + |
| 39 | +### Traits |
| 40 | + |
| 41 | +- **`SessionMessage`** — core trait for message types. Provides |
| 42 | + deserialization, serialization, header/admin extraction, and admin message |
| 43 | + construction. The session is generic: `Session<M: SessionMessage>`. |
| 44 | +- **`HeaderAccess`** — direct get/set access to header fields. Used by the |
| 45 | + session for filling outgoing headers, resend handling, and incoming |
| 46 | + validation. |
| 47 | + |
| 48 | +### Serializer / Deserializer |
| 49 | + |
| 50 | +FIX tag-value format encoding and decoding: |
| 51 | + |
| 52 | +- `Deserializer` — parses raw FIX bytes into typed fields |
| 53 | +- `Serializer` — writes typed fields to FIX tag-value format |
| 54 | +- `RawMessage` — structurally validated message (BeginString, BodyLength, |
| 55 | + CheckSum checked) ready for content parsing |
| 56 | +- `DeserializeError` — structured error with reject reason and metadata |
| 57 | + |
| 58 | +## Implementing custom message types |
| 59 | + |
| 60 | +For use cases where code generation from XML is not suitable, you can implement |
| 61 | +`SessionMessage` and `HeaderAccess` directly. See the |
| 62 | +[`dynamic_message`](examples/dynamic_message.rs) example for a complete |
| 63 | +reference implementation that stores fields in a `HashMap`. |
| 64 | + |
| 65 | +## Serde support |
| 66 | + |
| 67 | +Optional features for JSON/other format serialization of core types: |
| 68 | + |
| 69 | +```toml |
| 70 | +[dependencies] |
| 71 | +easyfix-core = { version = "0.1", features = ["serde-serialize", "serde-deserialize"] } |
| 72 | +``` |
| 73 | + |
| 74 | +## License |
| 75 | + |
| 76 | +MIT |
0 commit comments