Skip to main content

Field

Struct Field 

Source
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

Source

pub fn new(tag: u32, value: impl Into<Vec<u8>>) -> Self

Create a field from a tag and raw value bytes.

Source

pub fn string(tag: u32, value: &str) -> Self

Create a field from a tag and a string value.

Source

pub fn int(tag: u32, value: i64) -> Self

Create an integer-valued field.

Source

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.

Source

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.

Source

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.

Source

pub fn utc_date_only(tag: u32, value: Date) -> Self

Create a UTC-date-only-valued field (YYYYMMDD; FR-011).

Source

pub fn as_utc_date_only(&self) -> Result<Date, FieldError>

The value as a UTC date-only (YYYYMMDD; FR-011).

Source

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.

Source

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.

Source

pub fn tag(&self) -> u32

The field’s tag number.

Source

pub fn value_bytes(&self) -> &[u8]

The raw value bytes.

Source

pub fn as_str(&self) -> Result<&str, FieldError>

The value as a UTF-8 string slice.

Source

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.

Source

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.

Source

pub fn as_char(&self) -> Result<char, FieldError>

The value as a single character (FIX char).

Source

pub fn as_bool(&self) -> Result<bool, FieldError>

The value as a boolean (Y/N).

Source

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.

Trait Implementations§

Source§

impl Clone for Field

Source§

fn clone(&self) -> Field

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Field

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Field

Source§

impl PartialEq for Field

Source§

fn eq(&self, other: &Field) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Field

Auto Trait Implementations§

§

impl Freeze for Field

§

impl RefUnwindSafe for Field

§

impl Send for Field

§

impl Sync for Field

§

impl Unpin for Field

§

impl UnsafeUnpin for Field

§

impl UnwindSafe for Field

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.