Module field_types

Source
Expand description

A wide collection of FieldType implementors.

FIX datatypeSuggested FieldType implementors
intu32, i32, u64, i64, u128, i128.
Lengthusize.
NumInGroupusize.
SeqNumu64.
TagNumTagU32.
DayOfMonthu32.
float, Price, etc.f32, f64, [struct@rust_decimal::Decimal], [struct@decimal::d128].
Booleanbool.
charu8 1.
StringVec<u8>, &[u8].1
dataVec<u8>, &[u8] (also String, str for UTF-8 content).
MultipleCharValueMultipleChars 1.
MultipleValueStringMultipleStrings 1.
CountryCountry.
CurrencyCurrency.
ExchangeExchange.
month-yearMonthYear.
UTCTimeOnlyTime, chrono::NaiveTime.
UTCDateOnlyDate, chrono::NaiveDate.
UTCTimestampTimestamp, chrono::NaiveDateTime.
TZTimestampTzTimestamp, chrono::DateTime<chrono::FixedOffset>.
LocalMktDateDate, chrono::NaiveDate.
TZTimeOnlyTzTime,

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]);

  1. 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§

CheckSum
The result of a FIX checksum calculation (0-255).
Date
Representation for LocalMktDate and and UTCDateOnly in YYYYMMDD format.
MonthYear
Canonical data field (DTF) for FixDatatype::MonthYear.
MultipleChars
An Iterator over space-delimited bytes in a MultipleCharValue FIX field.
MultipleStrings
An Iterator over space-delimited byte sequences in a MultipleStringValue 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.
ZeroPadding
Zero-padding for integers; see FieldType::SerializeSettings.

Functions§

test_utility_verify_serialization_behavior
Tries to FieldType::serialize an item, then to FieldType::deserialize it, and finally checks for equality with the initial data. FieldType::deserialize_lossy is then tested in the same manner.

Type Aliases§

Country
Type alias for ISO 3166-1 alpha-2 strings (two-letter country codes).
Currency
Type alias for ISO 4217 alpha codes (three-letter currency codes).
Exchange
Type alias for four-letter Market Identifier Codes (MICs) as defined by ISO 10383.