Skip to main content

Message

Struct Message 

Source
pub struct Message {
    pub header: Header,
    pub trailer: Trailer,
    pub body: Body,
    pub receive_time: Timestamp,
    pub fields: Arc<[TagValue]>,
    /* private fields */
}
Expand description

A parsed or constructed FIX message.

A Message is split into three FieldMap sections – header, body, and trailer – mirroring the wire format of a FIX message. Each section has its own tag ordering rules.

§Building a Message

use fixer::message::Message;
use fixer::tag::*;
use fixer::fix_string::FIXString;

let mut msg = Message::new();
msg.header.set_field(TAG_BEGIN_STRING, FIXString::from("FIX.4.2"));
msg.header.set_field(TAG_MSG_TYPE, FIXString::from("D"));
msg.header.set_field(TAG_SENDING_TIME, FIXString::from("20140615-19:49:56"));
msg.body.set_string(11, "order-1");
msg.body.set_int(21, 1);

let bytes = msg.build();
assert!(!bytes.is_empty());

§Parsing a Message

use fixer::message::Message;

let raw = b"8=FIX.4.2\x019=30\x0135=D\x0149=TW\x0156=ISLD\x0111=id\x0121=3\x0110=079\x01";
let mut msg = Message::new();
msg.parse_message(raw).unwrap();

assert!(msg.is_msg_type_of("D"));
assert_eq!(msg.body.get_string(11).unwrap(), "id");

Fields§

§header: Header§trailer: Trailer§body: Body§receive_time: Timestamp§fields: Arc<[TagValue]>

Implementations§

Source§

impl Message

Source

pub fn new() -> Self

Creates a new empty message with initialized header, body, and trailer.

Source

pub fn copy_into(&self, to: &mut Message)

Deep-copies this message into to.

Source

pub fn parse_message(&mut self, raw_message: &[u8]) -> Result<(), ParseError>

Parses a FIX message from raw bytes, populating header, body, and trailer fields. Returns an error if the message is malformed.

Source

pub fn parse_message_with_data_dictionary( &mut self, raw_message: &[u8], transport_data_dictionary: &Option<Arc<DataDictionary>>, application_data_dictionary: &Option<Arc<DataDictionary>>, ) -> Result<(), ParseError>

Parses a FIX message using optional transport and application DataDictionary instances to correctly classify header and trailer fields.

Source

pub fn parse_message_with_dd_shared( &mut self, shared: &Bytes, transport_data_dictionary: &Option<Arc<DataDictionary>>, _application_data_dictionary: &Option<Arc<DataDictionary>>, ) -> Result<(), ParseError>

Parses a FIX message from a shared Bytes buffer, avoiding an extra allocation when the caller already holds Bytes (e.g. from the parser).

Source

pub fn msg_type(&self) -> Result<String, MessageRejectErrorEnum>

Returns the MsgType (tag 35) value from the header.

Source

pub fn is_msg_type_of(&self, msg_type: &str) -> bool

Returns true if the header’s MsgType (tag 35) equals msg_type.

Source

pub fn reverse_route(&self) -> Message

Creates a new message with routing header fields (sender/target comp IDs, sub IDs, location IDs, etc.) swapped from this message.

Source

pub fn build(&mut self) -> Vec<u8>

Serializes this message to FIX wire format, computing BodyLength and CheckSum automatically.

Source

pub fn build_with_body_bytes(&mut self, body_bytes: &[u8]) -> Vec<u8>

Constructs a Vec<u8> from a Message instance, using the given body_bytes. This is a workaround for the fact that repeating group field ordering is not preserved through parse → field map → serialize round-trips. This lets us pull the Message from the Store, parse it, update the Header (e.g. PossDupFlag, OrigSendingTime), and then build it back into bytes using the original raw body, bypassing field map serialization.

Source

pub fn as_bytes(&mut self) -> Vec<u8>

Returns the raw message bytes if available (from parsing), otherwise rebuilds the message from the field maps.

Trait Implementations§

Source§

impl Clone for Message

Source§

fn clone(&self) -> Message

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 Message

Source§

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

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

impl Default for Message

Source§

fn default() -> Message

Returns the “default value” for a type. Read more
Source§

impl Display for Message

Source§

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

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

impl Messageable for Message

Auto Trait Implementations§

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.