trafix_codec/message/field/value/
aliases.rs

1//! Definitions of type aliases used for common FIX field values.
2//!
3//! These aliases provide clearer semantic meaning when working with
4//! strongly typed [`Field`](crate::message::field::Field) variants.
5
6use std::convert::Infallible;
7
8use crate::message::field::value::FromFixBytes;
9
10/// Represents the `MsgSeqNum` (`34`).
11///
12/// This value increments with each message within a FIX session,
13/// ensuring ordering and detection of missing or duplicated messages.
14pub type MsgSeqNum = u64;
15
16/// Represents the `SenderCompID` (`49`).
17///
18/// Identifies the sender of the FIX message (typically the firm,
19/// system, or gateway). Stored as raw bytes to preserve any
20/// non-UTF-8 or fixed-width encodings.
21pub type SenderCompID = Vec<u8>;
22
23/// Represents the `SendingTime` (`52`).
24///
25/// Timestamp indicating when the message was sent.
26// TODO(kfejzic): Replace with a more specific time type, adhering to the
27// FIXs SendingTime ruling: YYYYMMDD-HH:MM:SS[.sss]
28pub type SendingTime = Vec<u8>;
29
30/// Represents the `TargetCompID` (`56`).
31///
32/// Identifies the intended recipient of the FIX message.
33/// Stored as raw bytes for full fidelity with on-wire data.
34pub type TargetCompID = Vec<u8>;
35
36impl FromFixBytes for Vec<u8> {
37    type Error<'unused> = Infallible;
38
39    fn from_fix_bytes(bytes: &[u8]) -> Result<Self, Self::Error<'_>>
40    where
41        Self: Sized,
42    {
43        Ok(bytes.into())
44    }
45}