pub struct Deserializer<'de> { /* private fields */ }Expand description
Reads typed FIX values out of a framed RawMessage, field by field.
A cursor walks the body: deserialize_tag_num
yields the next tag, and the matching deserialize_* call consumes that
tag’s value together with its SOH. String-valued reads borrow from the
original bytes, so parsing a message copies nothing that is not owned.
Generated code drives this in three phases - declare an Option per
field, loop over tags dispatching to deserialize_*, then build the
struct - and hands a tag back with put_tag when it
belongs to the next message section.
Implementations§
Source§impl<'de> Deserializer<'de>
impl<'de> Deserializer<'de>
Sourcepub fn from_raw_message(raw_message: RawMessage<'_>) -> Deserializer<'_>
pub fn from_raw_message(raw_message: RawMessage<'_>) -> Deserializer<'_>
Start reading raw_message’s body from its first tag.
Sourcepub fn begin_string(&self) -> FixString
pub fn begin_string(&self) -> FixString
BeginString(8), as an owned copy. Consumed by the framing, so it is read from here rather than from the tag stream.
Sourcepub fn body_length(&self) -> Length
pub fn body_length(&self) -> Length
BodyLength(9). Consumed by the framing, so it is read from here rather than from the tag stream.
Sourcepub fn check_sum(&self) -> FixString
pub fn check_sum(&self) -> FixString
CheckSum(10), zero-padded to three digits. Consumed by the framing, so it is read from here rather than from the tag stream.
Sourcepub fn set_seq_num(&mut self, seq_num: SeqNum)
pub fn set_seq_num(&mut self, seq_num: SeqNum)
Record MsgSeqNum(34) so a later reject can quote it.
Call once, right after reading tag 34; a second call is a bug and trips
a debug assertion. Without it a reject falls back to scanning the body
for 34=, which a binary field can defeat.
Sourcepub fn reject(
&mut self,
tag: Option<TagNum>,
reason: SessionRejectReasonBase,
) -> DeserializeErrorKind
pub fn reject( &mut self, tag: Option<TagNum>, reason: SessionRejectReasonBase, ) -> DeserializeErrorKind
Build a DeserializeErrorKind::Reject blaming tag for reason,
quoting the MsgSeqNum and MsgType read so far.
Returns DeserializeErrorKind::Logout instead when MsgSeqNum(34) was
neither recorded nor recoverable - a message without tag 34 is a logout
offence, not a reject (FIX Session Layer §4.5.3).
Sourcepub fn repeating_group_fields_out_of_order(
&mut self,
expected_tags: &[u16],
processed_tags: &[u16],
current_tag: u16,
) -> DeserializeErrorKind
pub fn repeating_group_fields_out_of_order( &mut self, expected_tags: &[u16], processed_tags: &[u16], current_tag: u16, ) -> DeserializeErrorKind
Build a RepeatingGroupFieldsOutOfOrder reject, blaming whichever tag
the group’s declared order says is misplaced.
expected_tags is the group’s field order from the dictionary,
processed_tags those already seen in this group instance, and
current_tag the one that triggered the check. When an earlier
processed tag should have come after current_tag, that tag is quoted
as RefTagID(371); otherwise current_tag is.
Sourcepub fn put_tag(&mut self, tag: TagNum)
pub fn put_tag(&mut self, tag: TagNum)
Push tag back so the next
deserialize_tag_num returns it again.
One tag of lookahead, used when a section’s parser reads a tag that belongs to the next section - a trailer tag surfacing while the body is still being read, say. A second push before the tag is taken overwrites the first.
Sourcepub fn field_cursor(&self) -> FieldCursor<'de>
pub fn field_cursor(&self) -> FieldCursor<'de>
Copy the current read position, including any pushed-back tag, into an independent cursor. Creating or advancing it leaves this deserializer unchanged. If a tag was already consumed without being pushed back, the cursor starts at that tag’s value.
Sourcepub fn range_to_fixstr(&self, range: Range<usize>) -> &FixStr
pub fn range_to_fixstr(&self, range: Range<usize>) -> &FixStr
Resolve a range handed out by
deserialize_msg_type back into the
bytes it names, borrowed from the message.
Only pass ranges this deserializer produced. A range from anywhere else
names bytes this deserializer never checked - a message body may hold
arbitrary bytes inside a Data field - and is rejected rather than
trusted.
§Panics
If range is out of the message body’s bounds, or names bytes that are
not printable ASCII. Either means the range did not come from here.
Sourcepub fn deserialize_msg_type(
&mut self,
) -> Result<Range<usize>, DeserializeErrorKind>
pub fn deserialize_msg_type( &mut self, ) -> Result<Range<usize>, DeserializeErrorKind>
Read MsgType(35) and remember it for later rejects.
Returns the value’s range within the message body rather than the
bytes, so the borrow ends here and the deserializer stays mutably
usable; resolve it with
range_to_fixstr when the bytes are needed.
Sourcepub fn deserialize_tag_num(
&mut self,
) -> Result<Option<TagNum>, DeserializeErrorKind>
pub fn deserialize_tag_num( &mut self, ) -> Result<Option<TagNum>, DeserializeErrorKind>
Deserialize sequence of character digits without commas or decimals. Value must be positive and may not contain leading zeros.
Sourcepub fn deserialize_int(&mut self) -> Result<Int, DeserializeErrorKind>
pub fn deserialize_int(&mut self) -> Result<Int, DeserializeErrorKind>
Deserialize sequence of character digits without commas or decimals
and optional sign character (characters - and 0 - 9).
The sign character utilizes one octet (i.e., positive int is 99999
while negative int is -99999).
Note that int values may contain leading zeros (e.g. 00023 = 23).
Sourcepub fn deserialize_seq_num(&mut self) -> Result<SeqNum, DeserializeErrorKind>
pub fn deserialize_seq_num(&mut self) -> Result<SeqNum, DeserializeErrorKind>
Deserialize sequence of character digits without commas or decimals. Value must be positive.
Sourcepub fn deserialize_num_in_group(
&mut self,
) -> Result<NumInGroup, DeserializeErrorKind>
pub fn deserialize_num_in_group( &mut self, ) -> Result<NumInGroup, DeserializeErrorKind>
Deserialize sequence of character digits without commas or decimals. Value must be positive.
Sourcepub fn deserialize_day_of_month(
&mut self,
) -> Result<DayOfMonth, DeserializeErrorKind>
pub fn deserialize_day_of_month( &mut self, ) -> Result<DayOfMonth, DeserializeErrorKind>
Deserialize sequence of character digits without commas or decimals (values 1 to 31).
Sourcepub fn deserialize_float(&mut self) -> Result<Float, DeserializeErrorKind>
pub fn deserialize_float(&mut self) -> Result<Float, DeserializeErrorKind>
Deserialize sequence of character digits with optional decimal point
and sign character (characters -, 0 - 9 and .);
the absence of the decimal point within the string will be interpreted
as the float representation of an integer value. Note that float values
may contain leading zeros (e.g. 00023.23 = 23.23) and may contain
or omit trailing zeros after the decimal point
(e.g. 23.0 = 23.0000 = 23 = 23.).
All float fields must accommodate up to fifteen significant digits. The number of decimal places used should be a factor of business/market needs and mutual agreement between counterparties.
Sourcepub fn deserialize_qty(&mut self) -> Result<Qty, DeserializeErrorKind>
pub fn deserialize_qty(&mut self) -> Result<Qty, DeserializeErrorKind>
Deserialize a Qty - the Float grammar under a different name.
Sourcepub fn deserialize_price(&mut self) -> Result<Price, DeserializeErrorKind>
pub fn deserialize_price(&mut self) -> Result<Price, DeserializeErrorKind>
Deserialize a Price - the Float grammar under a different name.
Sourcepub fn deserialize_price_offset(
&mut self,
) -> Result<PriceOffset, DeserializeErrorKind>
pub fn deserialize_price_offset( &mut self, ) -> Result<PriceOffset, DeserializeErrorKind>
Deserialize a PriceOffset - the Float grammar under a different
name.
Sourcepub fn deserialize_amt(&mut self) -> Result<Amt, DeserializeErrorKind>
pub fn deserialize_amt(&mut self) -> Result<Amt, DeserializeErrorKind>
Deserialize an Amt - the Float grammar under a different name.
Sourcepub fn deserialize_percentage(
&mut self,
) -> Result<Percentage, DeserializeErrorKind>
pub fn deserialize_percentage( &mut self, ) -> Result<Percentage, DeserializeErrorKind>
Deserialize a Percentage - the Float grammar under a different
name.
Sourcepub fn deserialize_boolean(&mut self) -> Result<Boolean, DeserializeErrorKind>
pub fn deserialize_boolean(&mut self) -> Result<Boolean, DeserializeErrorKind>
Deserialize a single-character boolean: Y for true, N for false.
Sourcepub fn deserialize_char(&mut self) -> Result<Char, DeserializeErrorKind>
pub fn deserialize_char(&mut self) -> Result<Char, DeserializeErrorKind>
Deserialize any ASCII character except control characters.
Sourcepub fn deserialize_multiple_char_value(
&mut self,
) -> Result<MultipleCharValue, DeserializeErrorKind>
pub fn deserialize_multiple_char_value( &mut self, ) -> Result<MultipleCharValue, DeserializeErrorKind>
Deserialize string containing one or more space-delimited single
character values, e.g. 2 A F.
Sourcepub fn deserialize_str(&mut self) -> Result<&FixStr, DeserializeErrorKind>
pub fn deserialize_str(&mut self) -> Result<&FixStr, DeserializeErrorKind>
Deserialize alphanumeric free-format strings can include any character except control characters.
Sourcepub fn deserialize_string(&mut self) -> Result<FixString, DeserializeErrorKind>
pub fn deserialize_string(&mut self) -> Result<FixString, DeserializeErrorKind>
Deserialize alphanumeric free-format strings can include any character except control characters.
Sourcepub fn deserialize_multiple_string_value(
&mut self,
) -> Result<MultipleStringValue, DeserializeErrorKind>
pub fn deserialize_multiple_string_value( &mut self, ) -> Result<MultipleStringValue, DeserializeErrorKind>
Deserialize string containing one or more space-delimited multiple
character values, e.g. AV AN A.
Sourcepub fn deserialize_country(&mut self) -> Result<Country, DeserializeErrorKind>
pub fn deserialize_country(&mut self) -> Result<Country, DeserializeErrorKind>
Deserialize ISO 3166-1:2013 Codes for the representation of names of countries and their subdivision (2-character code).
Sourcepub fn deserialize_currency(&mut self) -> Result<Currency, DeserializeErrorKind>
pub fn deserialize_currency(&mut self) -> Result<Currency, DeserializeErrorKind>
Deserialize ISO 4217:2015 Codes for the representation of currencies and funds (3-character code).
Sourcepub fn deserialize_exchange(&mut self) -> Result<Exchange, DeserializeErrorKind>
pub fn deserialize_exchange(&mut self) -> Result<Exchange, DeserializeErrorKind>
Deserialize ISO 10383:2012 Securities and related financial instruments - Codes for exchanges and market identification (MIC) (4-character code).
Sourcepub fn deserialize_month_year(
&mut self,
) -> Result<MonthYear, DeserializeErrorKind>
pub fn deserialize_month_year( &mut self, ) -> Result<MonthYear, DeserializeErrorKind>
Deserialize string representing month of a year. An optional day of the month can be appended or an optional week code.
§Valid formats:
YYYYMMYYYYMMDDYYYYMMWW
§Valid values:
- YYYY = 0000-9999
- MM = 01-12
- DD = 01-31
- WW = w1, w2, w3, w4, w5
The format is not enforced: the value is accepted as a plain string, and format conformance is left to the application.
Sourcepub fn deserialize_language(&mut self) -> Result<Language, DeserializeErrorKind>
pub fn deserialize_language(&mut self) -> Result<Language, DeserializeErrorKind>
Deserialize ISO 639-1:2002 Codes for the representation of names of languages (2-character code).
Sourcepub fn deserialize_utc_timestamp(
&mut self,
) -> Result<UtcTimestamp, DeserializeErrorKind>
pub fn deserialize_utc_timestamp( &mut self, ) -> Result<UtcTimestamp, DeserializeErrorKind>
Deserialize string representing time/date combination represented in UTC (Universal Time Coordinated) in either YYYYMMDD-HH:MM:SS (whole seconds) or YYYYMMDD-HH:MM:SS.sss* format, colons, dash, and period required.
§Valid values:
- YYYY = 0000-9999,
- MM = 01-12,
- DD = 01-31,
- HH = 00-23,
- MM = 00-59,
- SS = 00-60 (60 only if UTC leap second),
- sss* fractions of seconds. The fractions of seconds may be empty when no fractions of seconds are conveyed (in such a case the period is not conveyed), it may include 3 digits to convey milliseconds, 6 digits to convey microseconds, 9 digits to convey nanoseconds, 12 digits to convey picoseconds (truncated to nanosecond resolution);
Sourcepub fn deserialize_utc_time_only(
&mut self,
) -> Result<UtcTimeOnly, DeserializeErrorKind>
pub fn deserialize_utc_time_only( &mut self, ) -> Result<UtcTimeOnly, DeserializeErrorKind>
Deserialize string representing time-only represented in UTC (Universal Time Coordinated) in either HH:MM:SS (whole seconds) or HH:MM:SS.sss* (milliseconds) format, colons, and period required.
This special-purpose field is paired with UTCDateOnly to form a proper UTCTimestamp for bandwidth-sensitive messages.
§Valid values:
- HH = 00-23,
- MM = 00-59,
- SS = 00-60 (60 only if UTC leap second),
- sss* fractions of seconds. The fractions of seconds may be empty when no fractions of seconds are conveyed (in such a case the period is not conveyed), it may include 3 digits to convey milliseconds, 6 digits to convey microseconds, 9 digits to convey nanoseconds, 12 digits to convey picoseconds (truncated to nanosecond resolution);
Sourcepub fn deserialize_utc_date_only(
&mut self,
) -> Result<UtcDateOnly, DeserializeErrorKind>
pub fn deserialize_utc_date_only( &mut self, ) -> Result<UtcDateOnly, DeserializeErrorKind>
Deserialize date represented in UTC (Universal Time Coordinated) in YYYYMMDD format.
§Valid values:
- YYYY = 0000-9999,
- MM = 01-12,
- DD = 01-31.
Sourcepub fn deserialize_local_mkt_time(
&mut self,
) -> Result<LocalMktTime, DeserializeErrorKind>
pub fn deserialize_local_mkt_time( &mut self, ) -> Result<LocalMktTime, DeserializeErrorKind>
Deserialize time local to a market center. Used where offset to UTC varies throughout the year and the defining market center is identified in a corresponding field.
Format is HH:MM:SS where:
- HH = 00-23 hours,
- MM = 00-59 minutes,
- SS = 00-59 seconds.
In general only the hour token is non-zero.
Sourcepub fn deserialize_local_mkt_date(
&mut self,
) -> Result<LocalMktDate, DeserializeErrorKind>
pub fn deserialize_local_mkt_date( &mut self, ) -> Result<LocalMktDate, DeserializeErrorKind>
Deserialize date of local market (as opposed to UTC) in YYYYMMDD format.
§Valid values:
- YYYY = 0000-9999,
- MM = 01-12,
- DD = 01-31.
Sourcepub fn deserialize_tz_timestamp(
&mut self,
) -> Result<TzTimestamp, DeserializeErrorKind>
pub fn deserialize_tz_timestamp( &mut self, ) -> Result<TzTimestamp, DeserializeErrorKind>
Deserialize string representing a time/date combination representing local time with an offset to UTC to allow identification of local time and time zone offset of that time.
The representation is based on ISO 8601.
Format is YYYYMMDD-HH:MM[:SS][.sss*][Z | [ + | - hh[:mm]]] where:
- YYYY = 0000 to 9999,
- MM = 01-12,
- DD = 01-31,
- HH = 00-23 hours,
- MM = 00-59 minutes,
- SS = 00-59 seconds, optional on input (the spec’s own examples omit
them) and taken as
00when absent, - hh = 01-12 offset hours,
- mm = 00-59 offset minutes,
- sss* fractions of seconds. The fractions of seconds may be empty when no fractions of seconds are conveyed (in such a case the period is not conveyed), it may include 3 digits to convey milliseconds, 6 digits to convey microseconds, 9 digits to convey nanoseconds, 12 digits to convey picoseconds (truncated to nanosecond resolution);
Sourcepub fn deserialize_tz_timeonly(
&mut self,
) -> Result<TzTimeOnly, DeserializeErrorKind>
pub fn deserialize_tz_timeonly( &mut self, ) -> Result<TzTimeOnly, DeserializeErrorKind>
Deserialize time of day with timezone. Time represented based on ISO 8601. This is the time with a UTC offset to allow identification of local time and time zone of that time.
Format is HH:MM[:SS][Z | [ + | - hh[:mm]]] where:
- HH = 00-23 hours,
- MM = 00-59 minutes,
- SS = 00-59 seconds,
- hh = 01-12 offset hours,
- mm = 00-59 offset minutes.
Sourcepub fn deserialize_length(&mut self) -> Result<Length, DeserializeErrorKind>
pub fn deserialize_length(&mut self) -> Result<Length, DeserializeErrorKind>
Deserialize sequence of character digits without commas or decimals. Value must be positive. Fields of datatype Length are referred to as Length fields.
The Length field must be associated with a field of datatype data.
The Length field must specify the number of octets of the value
contained in the associated data field up to but not including
the terminating <SOH>.
Sourcepub fn deserialize_data(
&mut self,
len: usize,
) -> Result<Data, DeserializeErrorKind>
pub fn deserialize_data( &mut self, len: usize, ) -> Result<Data, DeserializeErrorKind>
Deserialize raw data with no format or content restrictions, or a character string encoded as specified by MessageEncoding(347). Fields of datatype data must have an associated field of type Length. Fields of datatype data must be immediately preceded by their associated Length field.
Sourcepub fn deserialize_xml(
&mut self,
len: usize,
) -> Result<XmlData, DeserializeErrorKind>
pub fn deserialize_xml( &mut self, len: usize, ) -> Result<XmlData, DeserializeErrorKind>
Deserialize XML document with characterstring repertoire specified as value of XML encoding declaration.
§Requirements
- A field of datatype XMLData must contain a well-formed document, as defined by the W3C XML recommendation.
- Fields of datatype XMLData must have an associated field of type Length.
- Fields of datatype XMLData must be immediately preceded by their associated Length field.
Sourcepub fn deserialize_tenor(&mut self) -> Result<Tenor, DeserializeErrorKind>
pub fn deserialize_tenor(&mut self) -> Result<Tenor, DeserializeErrorKind>
Deserialize a tenor: a unit code (D, M, W or Y) followed by
a non-zero value, e.g. M3 for three months.
Sourcepub fn deserialize_int_enum<T>(&mut self) -> Result<T, DeserializeErrorKind>
pub fn deserialize_int_enum<T>(&mut self) -> Result<T, DeserializeErrorKind>
Deserialize an Int and convert it into the enum T.
A value outside T’s variants is a Reject carrying the reason
T chose, blamed on the tag currently being read.
Sourcepub fn deserialize_num_in_group_enum<T>(
&mut self,
) -> Result<T, DeserializeErrorKind>
pub fn deserialize_num_in_group_enum<T>( &mut self, ) -> Result<T, DeserializeErrorKind>
Deserialize a NumInGroup and convert it into the enum T, with the
same reject behavior as
deserialize_int_enum.
Sourcepub fn deserialize_char_enum<T>(&mut self) -> Result<T, DeserializeErrorKind>
pub fn deserialize_char_enum<T>(&mut self) -> Result<T, DeserializeErrorKind>
Deserialize a Char and convert it into the enum T, with the same
reject behavior as
deserialize_int_enum.
Sourcepub fn deserialize_string_enum<T>(&mut self) -> Result<T, DeserializeErrorKind>
pub fn deserialize_string_enum<T>(&mut self) -> Result<T, DeserializeErrorKind>
Deserialize a FixStr and convert it into the enum T, with the same
reject behavior as
deserialize_int_enum.
Sourcepub fn deserialize_multiple_char_value_enum<T>(
&mut self,
) -> Result<Vec<T>, DeserializeErrorKind>
pub fn deserialize_multiple_char_value_enum<T>( &mut self, ) -> Result<Vec<T>, DeserializeErrorKind>
Deserialize a space-delimited MultipleCharValue and convert every
element into the enum T. The first element outside T’s variants
rejects the whole field.
Sourcepub fn deserialize_multiple_string_value_enum<T>(
&mut self,
) -> Result<Vec<T>, DeserializeErrorKind>
pub fn deserialize_multiple_string_value_enum<T>( &mut self, ) -> Result<Vec<T>, DeserializeErrorKind>
Deserialize a space-delimited MultipleStringValue and convert every
element into the enum T. The first element outside T’s variants
rejects the whole field.