Expand description
A wide collection of FieldType
implementors.
FIX datatype | Suggested FieldType implementors |
---|---|
int | u32 , i32 , u64 , i64 , u128 , i128 . |
Length | usize . |
NumInGroup | usize . |
SeqNum | u64 . |
TagNum | TagU32 . |
DayOfMonth | u32 . |
float , Price , etc. | f32 , f64 , [struct@rust_decimal::Decimal ], [struct@decimal::d128 ]. |
Boolean | bool . |
char | u8 1. |
String | Vec<u8> , &[u8] .1 |
data | Vec<u8> , &[u8] (also String , str for UTF-8 content). |
MultipleCharValue | MultipleChars 1. |
MultipleValueString | MultipleStrings 1. |
Country | Country . |
Currency | Currency . |
Exchange | Exchange . |
month-year | MonthYear . |
UTCTimeOnly | Time , chrono::NaiveTime . |
UTCDateOnly | Date , chrono::NaiveDate . |
UTCTimestamp | Timestamp , chrono::NaiveDateTime . |
TZTimestamp | TzTimestamp , chrono::DateTime<chrono::FixedOffset> . |
LocalMktDate | Date , chrono::NaiveDate . |
TZTimeOnly | TzTime , |
The above table provides some useful guidelines that work for the vast majority of use cases.
§Quick tour of FieldType
use hotfix_encoding::field_access::FieldType;
use hotfix_encoding::field_types::Timestamp;
let bytes = b"20130422-12:30:00.000";
// You can use `FieldType::deserialize` to parse data fields.
let timestamp = Timestamp::deserialize(bytes).unwrap();
assert_eq!(timestamp.date().year(), 2013);
// `FieldType::deserialize_lossy` is like `FieldType::deserialize`, but it's
// allowed to skip some format verification for the sake of speed.
assert!(u32::deserialize(b"invalid integer").is_err());
assert!(u32::deserialize_lossy(b"invalid integer").is_ok());
let mut buffer: Vec<u8> = vec![];
// Use `FieldType::serialize` to write values to buffers.
1337u32.serialize(&mut buffer);
assert_eq!(&buffer[..], b"1337" as &[u8]);
With the exception of datatype
data
, FIX mandates a single-byte encoding (Latin alphabet No. 1 by default), while Rust strings are UTF-8, which is a multibyte encoding. These are not compatible. Watch out! ↩
Structs§
- Check
Sum - The result of a FIX checksum calculation (0-255).
- Date
- Representation for
LocalMktDate
and andUTCDateOnly
inYYYYMMDD
format. - Month
Year - Canonical data field (DTF) for
FixDatatype::MonthYear
. - Multiple
Chars - An
Iterator
over space-delimited bytes in aMultipleCharValue
FIX field. - Multiple
Strings - An
Iterator
over space-delimited byte sequences in aMultipleStringValue
FIX field. - Time
- Canonical data field (DTF) for
FixDatatype::UtcTimeOnly
. - Timestamp
- Representation for
UtcTimestamp
. - Tz
- Timezone indicator.
- TzTime
- Timezone-aware intra-day timestamp.
- TzTimestamp
- A time and date combination representing local time with an offset from UTC.
- Zero
Padding - Zero-padding for integers; see
FieldType::SerializeSettings
.
Functions§
- test_
utility_ verify_ serialization_ behavior - Tries to
FieldType::serialize
anitem
, then toFieldType::deserialize
it, and finally checks for equality with the initial data.FieldType::deserialize_lossy
is then tested in the same manner.