Field

Enum Field 

Source
pub enum Field {
    MsgSeqNum(MsgSeqNum),
    SenderCompID(SenderCompID),
    SendingTime(SendingTime),
    TargetCompID(TargetCompID),
    Custom {
        tag: u16,
        value: Vec<u8>,
    },
}
Expand description

Represents a single FIX field.

Each variant corresponds to a strongly-typed FIX tag, such as MsgSeqNum(34) or SenderCompID(49). Fields not covered by predefined variants can be represented using Field::Custom.

Variants§

§

MsgSeqNum(MsgSeqNum)

Message sequence number (34).

Used to identify message ordering within a FIX session.

§

SenderCompID(SenderCompID)

Sender company or system identifier (49).

Identifies the sender of the message in a FIX session.

§

SendingTime(SendingTime)

Message sending time (52).

Timestamp representing when the message was sent.

§

TargetCompID(TargetCompID)

Target company or system identifier (56).

Identifies the intended recipient of the message in a FIX session.

§

Custom

Represents an arbitrary or user-defined FIX field not covered by the predefined variants.

Useful for extension tags, firm-specific fields, or when working with non-standard message structures.

Fields

§tag: u16

Tag of the custom field.

§value: Vec<u8>

Contents of the custom field.

Implementations§

Source§

impl Field

Source

pub fn try_new(tag: u16, bytes: &[u8]) -> Result<Self, Box<dyn Error>>

Tries to construct a new Field from the given tag and value.

§Errors

This function might return error if invalid values are passed for the given tag.

Source

pub fn tag(&self) -> u16

Returns the numeric FIX tag associated with this field.

Example usage:

use trafix_codec::message::field::{Field, value::aliases::MsgSeqNum};
let f = Field::MsgSeqNum(1);
assert_eq!(f.tag(), 34);
Source

pub fn value(&self) -> Vec<u8>

Returns the serialized value of the field as raw bytes.

For predefined fields, this returns their encoded textual representation (e.g. integer → ASCII). For custom fields, the original byte vector is cloned.

Source

pub fn encode(&self) -> Vec<u8>

Serializes the field into its "tag=value" representation.

This does not append the SOH delimiter; it only produces the byte content for a single field. The encoder is responsible for joining fields with SOH (0x01).

use trafix_codec::message::field::{Field, value::aliases::MsgSeqNum};
let f = Field::MsgSeqNum(4);
assert_eq!(f.encode(), b"34=4".to_vec());

Trait Implementations§

Source§

impl Clone for Field

Source§

fn clone(&self) -> Field

Returns a duplicate of the value. Read more
1.0.0 · 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 PartialEq for Field

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
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 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.