pub struct Field { /* private fields */ }Expand description
A single FIX field: a tag number and its raw (wire) value bytes.
Raw bytes are preserved verbatim so re-encoding reproduces the original representation (round-trip fidelity, FR-B9). Typed accessors convert on demand and never panic.
Implementations§
Source§impl Field
impl Field
Sourcepub fn new(tag: u32, value: impl Into<Vec<u8>>) -> Self
pub fn new(tag: u32, value: impl Into<Vec<u8>>) -> Self
Create a field from a tag and raw value bytes.
Sourcepub fn utc_timestamp(tag: u32, value: OffsetDateTime) -> Self
pub fn utc_timestamp(tag: u32, value: OffsetDateTime) -> Self
Create a UTC-timestamp-valued field at millisecond precision
(YYYYMMDD-HH:MM:SS.sss) — the FIX wire format, which does not match
OffsetDateTime’s own Display output. Sessions needing other precisions format their
own SendingTime; this constructor is the safe default for typed-message setters.
Sourcepub fn bytes(tag: u32, value: &[u8]) -> Self
pub fn bytes(tag: u32, value: &[u8]) -> Self
Create a Data-typed field from raw bytes (e.g. RawData/tag 96), preserving them
verbatim — including embedded SOH — since Data fields are not text (FR-011). A thin,
semantically-named wrapper over Self::new/Self::value_bytes, distinguishing “this is
a Data field” call sites from generic byte construction.
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
The value as raw bytes, with no UTF-8 assumption (FIX Data fields; FR-011). Equivalent to
Self::value_bytes, named for symmetry with Self::bytes.
Sourcepub fn utc_date_only(tag: u32, value: Date) -> Self
pub fn utc_date_only(tag: u32, value: Date) -> Self
Create a UTC-date-only-valued field (YYYYMMDD; FR-011).
Sourcepub fn as_utc_date_only(&self) -> Result<Date, FieldError>
pub fn as_utc_date_only(&self) -> Result<Date, FieldError>
The value as a UTC date-only (YYYYMMDD; FR-011).
Sourcepub fn utc_time_only(tag: u32, value: Time) -> Self
pub fn utc_time_only(tag: u32, value: Time) -> Self
Create a UTC-time-only-valued field at millisecond precision (HH:MM:SS.sss; FR-011),
matching Self::utc_timestamp’s precision convention.
Sourcepub fn as_utc_time_only(&self) -> Result<Time, FieldError>
pub fn as_utc_time_only(&self) -> Result<Time, FieldError>
The value as a UTC time-only (HH:MM:SS[.fraction]; FR-011). Accepts only 0/3/6/9
fractional digits (BUG-48/FR-046, feature 007) and maps a leap second to 59 plus the
maximum sub-second fraction (BUG-78), matching Self::as_utc_timestamp’s tolerance.
Sourcepub fn value_bytes(&self) -> &[u8] ⓘ
pub fn value_bytes(&self) -> &[u8] ⓘ
The raw value bytes.
Sourcepub fn as_str(&self) -> Result<&str, FieldError>
pub fn as_str(&self) -> Result<&str, FieldError>
The value as a UTF-8 string slice.
Sourcepub fn as_int(&self) -> Result<i64, FieldError>
pub fn as_int(&self) -> Result<i64, FieldError>
The value as an integer.
NEW-101 (audit 006): the raw wire value is parsed as-is, without trimming whitespace –
i64::from_str already rejects leading/trailing whitespace on its own, so the previous
.trim() call was the only thing making a whitespace-padded value like " 123 " parse
successfully, silently accepting a malformed wire value FIX never produces.
Sourcepub fn as_decimal(&self) -> Result<Decimal, FieldError>
pub fn as_decimal(&self) -> Result<Decimal, FieldError>
The value as a fixed-precision decimal (FIX Price/Qty/Amt).
NEW-101 (audit 006): see Self::as_int’s doc – the same whitespace-padding leniency is
closed here.
Sourcepub fn as_char(&self) -> Result<char, FieldError>
pub fn as_char(&self) -> Result<char, FieldError>
The value as a single character (FIX char).
Sourcepub fn as_bool(&self) -> Result<bool, FieldError>
pub fn as_bool(&self) -> Result<bool, FieldError>
The value as a boolean (Y/N).
Sourcepub fn as_utc_timestamp(&self) -> Result<OffsetDateTime, FieldError>
pub fn as_utc_timestamp(&self) -> Result<OffsetDateTime, FieldError>
The value as a UTC timestamp (FR-B7). Accepts only 0/3/6/9 fractional digits (BUG-48/
FR-046, feature 007), matching QFJ; a leap second (sec == 60) maps to 59 plus the
maximum sub-second fraction (BUG-78), matching QFJ’s explicit handling.