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
impl Message
Sourcepub fn parse_message(&mut self, raw_message: &[u8]) -> Result<(), ParseError>
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.
Sourcepub 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>
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.
Parses a FIX message from a shared Bytes buffer, avoiding an extra
allocation when the caller already holds Bytes (e.g. from the parser).
Sourcepub fn msg_type(&self) -> Result<String, MessageRejectErrorEnum>
pub fn msg_type(&self) -> Result<String, MessageRejectErrorEnum>
Returns the MsgType (tag 35) value from the header.
Sourcepub fn is_msg_type_of(&self, msg_type: &str) -> bool
pub fn is_msg_type_of(&self, msg_type: &str) -> bool
Returns true if the header’s MsgType (tag 35) equals msg_type.
Sourcepub fn reverse_route(&self) -> Message
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.
Sourcepub fn build(&mut self) -> Vec<u8> ⓘ
pub fn build(&mut self) -> Vec<u8> ⓘ
Serializes this message to FIX wire format, computing BodyLength
and CheckSum automatically.
Sourcepub fn build_with_body_bytes(&mut self, body_bytes: &[u8]) -> Vec<u8> ⓘ
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.