FixMessage

Struct FixMessage 

pub struct FixMessage { /* private fields */ }
Expand description

Safe Rust wrapper for FIXMessage

Implementations§

§

impl FixMessage

pub fn new(msg_type: &str, parser_id: i32) -> Result<Self, String>

Create a new FIX message skeleton

§Arguments
  • msg_type - Message type (e.g., “D” for NewOrderSingle)
  • parser_id - Parser ID (integer identifier for the FIX parser)
§Example
use fixantenna_bindings::FixMessage;
let parser_id = 4; // Example: FIX.4.4 parser ID
let msg = FixMessage::new("D", parser_id).unwrap();
assert_eq!(msg.msg_type().unwrap(), "D");

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

Get message type (MsgType field, tag 35)

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 4; // Example: FIX.4.4 parser ID
let msg = FixMessage::new("D", parser_id).unwrap();
assert_eq!(msg.msg_type().unwrap(), "D");

pub fn set(&mut self, tag: i32, value: &str) -> Result<(), String>

Set a field value by tag number

§Arguments
  • tag - FIX tag number (e.g., 55 for Symbol)
  • value - Field value as string
§Returns

Ok(()) on success, Err(String) on failure

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set(55, "AAPL").unwrap(); // Set Symbol field
msg.set(54, "1").unwrap();    // Set Side field (1=Buy)

pub fn get(&self, tag: i32) -> Option<String>

Get a field value by tag number

§Arguments
  • tag - FIX tag number (e.g., 55 for Symbol)
§Returns

Some(String) if field exists, None if field doesn’t exist

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set(55, "AAPL").unwrap();
assert_eq!(msg.get(55), Some("AAPL".to_string()));
assert_eq!(msg.get(999), None); // Non-existent field

pub fn has_value(&self, tag: i32) -> bool

Check if a field has a value

§Arguments
  • tag - FIX tag number
§Returns

true if field exists and has a non-empty value, false otherwise

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set(55, "AAPL").unwrap();
assert!(msg.has_value(55));
assert!(!msg.has_value(999));

pub fn is_supported(&self, tag: i32) -> bool

Check if a field/tag is supported for this message type

Returns true if the tag is valid for the current message type according to the FIX dictionary, regardless of whether it’s currently set.

§Arguments
  • tag - FIX tag number to check
§Returns

true if the tag is supported for this message type, false otherwise

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
assert!(msg.is_supported(55)); // Symbol is supported in NewOrderSingle
assert!(!msg.is_supported(9999)); // Invalid tag

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

Convert message to FIX protocol string representation

§Returns

FIX protocol formatted string (e.g., “8=FIX.4.4\x019=…\x01…”)

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set(55, "AAPL").unwrap();
let fix_string = msg.to_string().unwrap();
assert!(fix_string.contains("AAPL"));

pub fn set_int(&mut self, tag: i32, value: i64) -> Result<(), String>

Set a field value as i64 by tag number

§Arguments
  • tag - FIX tag number (e.g., 38 for OrderQty)
  • value - Field value as i64
§Returns

Ok(()) on success, Err(String) on failure

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set_int(38, 1000).unwrap(); // Set OrderQty field

pub fn set_double(&mut self, tag: i32, value: f64) -> Result<(), String>

Set a field value as f64 by tag number

§Arguments
  • tag - FIX tag number (e.g., 44 for Price)
  • value - Field value as f64
§Returns

Ok(()) on success, Err(String) on failure

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set_double(44, 123.45).unwrap(); // Set Price field

pub fn get_int(&self, tag: i32) -> Result<i64, String>

Get a field value as i64 by tag number

§Arguments
  • tag - FIX tag number (e.g., 38 for OrderQty)
§Returns

Ok(i64) if field exists and can be parsed, Err(String) with error details if field doesn’t exist or error occurred

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set_int(38, 1000).unwrap();
assert_eq!(msg.get_int(38), Ok(1000));
// msg.get_int(999).unwrap(); // Non-existent field - panics with error message

pub unsafe fn set_int64_unchecked( &mut self, tag: i32, value: i64, ) -> Result<(), Exception>

Set an int64 field value without error context (unchecked - bypasses .map_err)

§Safety

This is unsafe because it bypasses the error context mapping. Use only in performance-critical paths where error messages are not needed.

pub unsafe fn get_int64_unchecked(&self, tag: i32) -> i64

Get a field value as i64 - zero-cost unchecked version.

This bypasses CXX’s Result wrapper for maximum performance (~6ns faster than checked version).

§Safety
  • The message pointer must be valid
  • The tag must exist in the message
  • The tag must have the correct type (i64)
  • If C++ throws an exception, this causes undefined behavior
§Performance

Eliminates FFI Result overhead, achieving near-native C++ performance.

pub fn get_double(&self, tag: i32) -> Result<f64, String>

Get a field value as f64 by tag number

§Arguments
  • tag - FIX tag number (e.g., 44 for Price)
§Returns

Ok(f64) if field exists and can be parsed, Err(String) with error details if field doesn’t exist or error occurred

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set_double(44, 123.45).unwrap();
assert_eq!(msg.get_double(44), Ok(123.45));
// msg.get_double(999).unwrap(); // Non-existent field - panics with error message

pub unsafe fn set_double_unchecked( &mut self, tag: i32, value: f64, ) -> Result<(), Exception>

Set a double field value without error context (unchecked - bypasses .map_err)

§Safety

This is unsafe because it bypasses the error context mapping. Use only in performance-critical paths where error messages are not needed.

pub unsafe fn get_double_unchecked(&self, tag: i32) -> f64

Get a field value as f64 - zero-cost unchecked version.

This bypasses CXX’s Result wrapper for maximum performance (~6ns faster than checked version).

§Safety
  • The message pointer must be valid
  • The tag must exist in the message
  • The tag must have the correct type (f64/double)
  • If C++ throws an exception, this causes undefined behavior
§Performance

Eliminates FFI Result overhead, achieving near-native C++ performance.

pub fn set_int32(&mut self, tag: i32, value: i32) -> Result<(), String>

Set a field value as i32 by tag number

§Arguments
  • tag - FIX tag number
  • value - Field value as i32
§Returns

Ok(()) on success, Err(String) on failure

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set_int32(263, 1).unwrap(); // Set SubscriptionRequestType

pub unsafe fn set_int32_unchecked( &mut self, tag: i32, value: i32, ) -> Result<(), Exception>

Set a field value as i32 - unsafe version without error context mapping. For performance-critical code where the overhead of error formatting matters.

§Safety

The message pointer must be valid.

pub fn get_int32(&self, tag: i32) -> Result<i32, String>

Get a field value as i32 by tag number

§Arguments
  • tag - FIX tag number
§Returns

Ok(i32) if field exists and can be parsed, Err(()) if field doesn’t exist or error occurred

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set_int32(263, 1).unwrap();
assert_eq!(msg.get_int32(263).unwrap(), 1);
// msg.get_int32(999).unwrap(); // Non-existent field - panics

pub unsafe fn get_int32_unchecked(&self, tag: i32) -> i32

Get a field value as i32 - zero-cost unchecked version.

This bypasses CXX’s Result wrapper for maximum performance (~6ns faster than checked version).

§Safety
  • The message pointer must be valid
  • The tag must exist in the message
  • The tag must have the correct type (i32)
  • If C++ throws an exception, this causes undefined behavior
§Performance

Eliminates FFI Result overhead, achieving near-native C++ performance.

pub fn set_uint32(&mut self, tag: i32, value: u32) -> Result<(), String>

Set a field value as u32 by tag number

§Arguments
  • tag - FIX tag number
  • value - Field value as u32
§Returns

Ok(()) on success, Err(String) on failure

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set_uint32(34, 100).unwrap(); // Set MsgSeqNum

pub fn get_uint32(&self, tag: i32) -> Result<u32, String>

Get a field value as u32 by tag number

§Arguments
  • tag - FIX tag number
§Returns

Ok(u32) if field exists and can be parsed, Err(String) with error details if field doesn’t exist or error occurred

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set_uint32(34, 100).unwrap();
assert_eq!(msg.get_uint32(34), Ok(100));
// msg.get_uint32(999).unwrap(); // Non-existent field - panics with error message

pub unsafe fn set_uint32_unchecked( &mut self, tag: i32, value: u32, ) -> Result<(), Exception>

Set a uint32 field value without error context (unchecked - bypasses .map_err)

§Safety

This is unsafe because it bypasses the error context mapping. Use only in performance-critical paths where error messages are not needed.

pub unsafe fn get_uint32_unchecked(&self, tag: i32) -> u32

Get a field value as u32 - zero-cost unchecked version.

This bypasses CXX’s Result wrapper for maximum performance (~6ns faster than checked version).

§Safety
  • The message pointer must be valid
  • The tag must exist in the message
  • The tag must have the correct type (u32)
  • If C++ throws an exception, this causes undefined behavior
§Performance

Eliminates FFI Result overhead, achieving near-native C++ performance.

pub fn set_uint64(&mut self, tag: i32, value: u64) -> Result<(), String>

Set a field value as u64 by tag number

§Arguments
  • tag - FIX tag number
  • value - Field value as u64
§Returns

Ok(()) on success, Err(String) on failure

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set_uint64(11, 1234567890).unwrap(); // Set ClOrdID as number

pub fn get_uint64(&self, tag: i32) -> Result<u64, String>

Get a field value as u64 by tag number

§Arguments
  • tag - FIX tag number
§Returns

Ok(u64) if field exists and can be parsed, Err(String) with error details if field doesn’t exist or error occurred

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set_uint64(11, 1234567890).unwrap();
assert_eq!(msg.get_uint64(11), Ok(1234567890));
// msg.get_uint64(999).unwrap(); // Non-existent field - panics with error message

pub unsafe fn set_uint64_unchecked( &mut self, tag: i32, value: u64, ) -> Result<(), Exception>

Set a uint64 field value without error context (unchecked - bypasses .map_err)

§Safety

This is unsafe because it bypasses the error context mapping. Use only in performance-critical paths where error messages are not needed.

pub unsafe fn get_uint64_unchecked(&self, tag: i32) -> u64

Get a field value as u64 - zero-cost unchecked version.

This bypasses CXX’s Result wrapper for maximum performance (~6ns faster than checked version).

§Safety
  • The message pointer must be valid
  • The tag must exist in the message
  • The tag must have the correct type (u64)
  • If C++ throws an exception, this causes undefined behavior
§Performance

Eliminates FFI Result overhead, achieving near-native C++ performance.

pub fn set_decimal(&mut self, tag: i32, value: Decimal) -> Result<(), String>

Set a field value as Decimal by tag number

Decimal type provides precise decimal arithmetic for financial calculations, avoiding floating-point precision issues. Internally represented as mantissa and exponent.

§Arguments
  • tag - FIX tag number (e.g., 44 for Price)
  • value - Field value as rust_decimal::Decimal
§Returns

Ok(()) on success, Err(String) on failure

§Example
use fixantenna_bindings::FixMessage;
use rust_decimal::Decimal;
use std::str::FromStr;

let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
let price = Decimal::from_str("123.45").unwrap();
msg.set_decimal(44, price).unwrap(); // Set Price field

pub fn get_decimal(&self, tag: i32) -> Result<Decimal, String>

Get a field value as Decimal by tag number

Decimal type provides precise decimal arithmetic for financial calculations, avoiding floating-point precision issues.

§Arguments
  • tag - FIX tag number (e.g., 44 for Price)
§Returns

Ok(Decimal) if field exists and can be parsed, Err(String) with error details if field doesn’t exist or error occurred

§Example
use fixantenna_bindings::FixMessage;
use rust_decimal::Decimal;
use std::str::FromStr;

let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
let price = Decimal::from_str("123.45").unwrap();
msg.set_decimal(44, price).unwrap();
assert_eq!(msg.get_decimal(44), Ok(price));
// msg.get_decimal(999).unwrap(); // Non-existent field - panics with error message

pub fn set_bool(&mut self, tag: i32, value: bool) -> Result<(), String>

Set a field value as bool by tag number

§Arguments
  • tag - FIX tag number
  • value - Field value as bool (true/false)
§Returns

Ok(()) on success, Err(String) on failure

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set_bool(114, true).unwrap(); // Set LocateReqd field

pub fn get_bool(&self, tag: i32) -> Result<bool, String>

Get a field value as bool by tag number

§Arguments
  • tag - FIX tag number
§Returns

Ok(bool) if field exists and can be parsed, Err(String) with error details if field doesn’t exist or error occurred

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set_bool(114, true).unwrap();
assert_eq!(msg.get_bool(114), Ok(true));
// msg.get_bool(999).unwrap(); // Non-existent field - panics with error message

pub unsafe fn set_bool_unchecked( &mut self, tag: i32, value: bool, ) -> Result<(), Exception>

Set a bool field value without error context (unchecked - bypasses .map_err)

§Safety

This is unsafe because it bypasses the error context mapping. Use only in performance-critical paths where error messages are not needed.

pub unsafe fn get_bool_unchecked(&self, tag: i32) -> bool

Get a field value as bool - zero-cost unchecked version.

This bypasses CXX’s Result wrapper for maximum performance (~6ns faster than checked version).

§Safety
  • The message pointer must be valid
  • The tag must exist in the message
  • The tag must have the correct type (bool)
  • If C++ throws an exception, this causes undefined behavior
§Performance

Eliminates FFI Result overhead, achieving near-native C++ performance.

pub fn set_char(&mut self, tag: i32, value: char) -> Result<(), String>

Set a field value as char by tag number

§Arguments
  • tag - FIX tag number
  • value - Field value as char (single ASCII character)
§Returns

Ok(()) on success, Err(String) on failure

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set_char(54, '1').unwrap(); // Set Side field (1=Buy)

pub fn get_char(&self, tag: i32) -> Result<char, String>

Get a field value as char by tag number

§Arguments
  • tag - FIX tag number
§Returns

Ok(char) if field exists and can be parsed, Err(String) with error details if field doesn’t exist or error occurred

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set_char(54, '1').unwrap();
assert_eq!(msg.get_char(54), Ok('1'));
// msg.get_char(999).unwrap(); // Non-existent field - panics with error message

pub unsafe fn set_char_unchecked( &mut self, tag: i32, value: char, ) -> Result<(), Exception>

Set a char field value without error context (unchecked - bypasses .map_err)

§Safety

This is unsafe because it bypasses the error context mapping. Use only in performance-critical paths where error messages are not needed.

pub unsafe fn get_char_unchecked(&self, tag: i32) -> char

Get a field value as char - zero-cost unchecked version.

This bypasses CXX’s Result wrapper for maximum performance (~6ns faster than checked version).

§Safety
  • The message pointer must be valid
  • The tag must exist in the message
  • The tag must have the correct type (char)
  • If C++ throws an exception, this causes undefined behavior
§Performance

Eliminates FFI Result overhead, achieving near-native C++ performance.

pub fn get_string(&self, tag: i32) -> Result<String, String>

Get a field value as String by tag number

§Arguments
  • tag - FIX tag number
§Returns

Ok(String) if field exists, Err(String) with error details if field doesn’t exist or error occurred

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set(55, "MSFT").unwrap(); // Symbol
assert_eq!(msg.get_string(55), Ok("MSFT".to_string()));
// msg.get_string(999).unwrap(); // Non-existent field - panics with error message

pub fn get_string_ref(&self, tag: i32) -> Result<&str, String>

Get a field value as string reference by tag number (zero-copy)

Returns a string slice that borrows directly from the message’s internal storage. This avoids allocation but requires careful lifetime management.

§Safety

The returned string slice is only valid as long as:

  1. The message is not modified (no set, remove, etc.)
  2. The message is not dropped
§Arguments
  • tag - FIX tag number
§Returns

Ok(&str) if field exists, Err(String) with error details if field doesn’t exist or error occurred

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set(55, "MSFT").unwrap(); // Symbol
assert_eq!(msg.get_string_ref(55), Ok("MSFT"));
// The slice is valid until the message is modified or dropped

pub fn remove(&self, tag: i32) -> bool

Remove a field from the message

Empties the field value by tag number. Returns whether the field had a value before removal.

§Arguments
  • tag - FIX tag number to remove
§Returns

true if the field had a value before removal, false if field was already empty or doesn’t exist

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set(38, "5000").unwrap();
assert!(msg.remove(38)); // Returns true - field had value
assert!(!msg.remove(38)); // Returns false - field already removed

pub fn get_group(&self, leading_tag: i32) -> Option<FixGroup>

Get repeating group by leading tag

Returns a FixGroup wrapper if the group exists, None otherwise.

§Arguments
  • leading_tag - The leading field tag (NoXxx field) for the group
§Returns

Some(FixGroup) if group exists, None otherwise

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 4; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set(453, "2").unwrap(); // NoPartyIDs = 2

if let Some(group) = msg.get_group(453) {
    println!("Group has {} entries", group.size());
}

pub fn sender_comp_id(&self) -> String

Get SenderCompID (tag 49)

Returns the sender’s company ID from the message header.

§Returns

SenderCompID string, or empty string if not set

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set_sender_comp_id("SENDER123");
assert_eq!(msg.sender_comp_id(), "SENDER123");

pub fn set_sender_comp_id(&mut self, sender_id: &str) -> Result<(), String>

Set SenderCompID (tag 49)

Sets the sender’s company ID in the message header.

§Arguments
  • sender_id - Sender company ID (e.g., “SENDER123”)
§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set_sender_comp_id("SENDER123").unwrap();
assert_eq!(msg.sender_comp_id(), "SENDER123");

pub fn target_comp_id(&self) -> String

Get TargetCompID (tag 56)

Returns the target’s company ID from the message header.

§Returns

TargetCompID string, or empty string if not set

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set_target_comp_id("TARGET123");
assert_eq!(msg.target_comp_id(), "TARGET123");

pub fn set_target_comp_id(&mut self, target_id: &str) -> Result<(), String>

Set TargetCompID (tag 56)

Sets the target’s company ID in the message header.

§Arguments
  • target_id - Target company ID (e.g., “TARGET123”)
§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set_target_comp_id("TARGET123").unwrap();
assert_eq!(msg.target_comp_id(), "TARGET123");

pub fn seq_num(&self) -> Result<i32, String>

Get MsgSeqNum (tag 34)

Returns the message sequence number from the message header.

§Returns

Ok(i32) with sequence number on success, Err(String) on failure

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set_seq_num(42).unwrap();
assert_eq!(msg.seq_num().unwrap(), 42);

pub fn set_seq_num(&mut self, seq_num: i32) -> Result<(), String>

Set MsgSeqNum (tag 34)

Sets the message sequence number in the message header.

§Arguments
  • seq_num - Sequence number (positive integer)
§Returns

Ok(()) on success, Err(String) on failure

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set_seq_num(42).unwrap();
assert_eq!(msg.seq_num().unwrap(), 42);

pub fn heart_beat_interval(&self) -> Result<i32, String>

Get HeartBtInt field (tag 108)

Returns the heartbeat interval in seconds from the message.

§Returns

Ok(i32) with heartbeat interval on success, Err(String) on failure

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("A", parser_id).unwrap(); // Logon message
msg.set_heart_beat_interval(30).unwrap();
assert_eq!(msg.heart_beat_interval().unwrap(), 30);

pub fn set_heart_beat_interval(&mut self, hbi: i32) -> Result<(), String>

Set HeartBtInt field (tag 108)

Sets the heartbeat interval in seconds in the message.

§Arguments
  • hbi - Heartbeat interval in seconds (positive integer)
§Returns

Ok(()) on success, Err(String) on failure

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("A", parser_id).unwrap(); // Logon message
msg.set_heart_beat_interval(30).unwrap();
assert_eq!(msg.heart_beat_interval().unwrap(), 30);

pub fn is_original(&self) -> bool

Check if message is original (not a duplicate)

Returns true if PossDupFlag (tag 43) is not set or equals ‘N’. Returns false if PossDupFlag equals ‘Y’ (indicating a duplicate).

§Returns

true if message is original, false if it’s a duplicate

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let msg = FixMessage::new("D", parser_id).unwrap();
assert!(msg.is_original()); // New messages are original by default

pub fn is_business_reject(&self) -> bool

Check if message is a Business Message Reject

Returns true if the message type is ‘j’ (Business Message Reject).

§Returns

true if message is a business reject, false otherwise

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let msg = FixMessage::new("j", parser_id).unwrap();
assert!(msg.is_business_reject());

pub fn is_session_reject(&self) -> bool

Check if message is a Session Level Reject

Returns true if the message type is ‘3’ (Session Level Reject).

§Returns

true if message is a session reject, false otherwise

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let msg = FixMessage::new("3", parser_id).unwrap();
assert!(msg.is_session_reject());

pub fn is_administrative(&self) -> bool

Check if message is administrative (session level)

Returns true if the message is a session level message (e.g., Logon, Logout, Heartbeat, etc.). Returns false if the message is an application level message.

§Returns

true if message is administrative, false if it’s an application message

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let logon = FixMessage::new("A", parser_id).unwrap();
assert!(logon.is_administrative()); // Logon is administrative

let order = FixMessage::new("D", parser_id).unwrap();
assert!(!order.is_administrative()); // NewOrderSingle is not administrative

pub fn to_raw(&self) -> Result<Vec<u8>, String>

Convert message to binary FIX protocol format

Returns the raw binary representation of the message with SOH (0x01) delimiters. This is the actual wire format used for FIX transmission.

§Returns

Binary message data as Vec<u8>, or empty vector on error

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set(55, "AAPL").unwrap();
let raw_bytes = msg.to_raw().unwrap();
assert!(!raw_bytes.is_empty());
// Raw bytes contain SOH (0x01) as field delimiter
assert!(raw_bytes.contains(&0x01));

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

Convert message to JSON representation

Returns the message in JSON format according to “Encoding FIX using JSON” standard.

Note: This method requires messages to be fully parsed (not skeleton messages). Skeleton messages created with new() may not work correctly with to_json(). Use from_json() to create messages that can be serialized to JSON.

§Returns

JSON string representation, or empty string on error

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set(55, "AAPL").unwrap();
msg.set(54, "1").unwrap(); // Side=Buy
let json = msg.to_json().unwrap();
assert!(json.contains("AAPL"));

pub fn from_json(json_msg: &str, parser_id: i32) -> Result<Self, String>

Parse a FIX message from JSON format

Creates a FIXMessage from a JSON string according to “Encoding FIX using JSON” standard. The JSON must follow the FIX JSON schema with Header, Body, and Trailer sections.

§Arguments
  • json_msg - JSON string containing the FIX message
  • parser_id - Parser ID to use for parsing (e.g., 6 for FIX.4.4)
§Returns

Ok(FixMessage) on success, Err(String) if parsing fails

§Example
use fixantenna_bindings::FixMessage;
let json = r#"{"Header":{"MsgType":"D"},"Body":{"Symbol":"AAPL"},"Trailer":{}}"#;
let parser_id = 6; // FIX.4.4
let msg = FixMessage::from_json(json, parser_id).unwrap();
assert_eq!(msg.msg_type().unwrap(), "D");
assert_eq!(msg.get(55), Some("AAPL".to_string()));

pub fn from_string(fix_msg: &str, parser_id: i32) -> Result<Self, String>

Parse a FIX message from FIX protocol string

This is essential for parsing FIX messages received from the wire or stored in logs. The message string should be in standard FIX format with SOH (0x01) delimiters.

§Arguments
  • fix_msg - FIX protocol string (with SOH delimiters)
  • parser_id - Parser/dictionary ID (see FIXVersion enum for values)
§Returns

New FixMessage on success, or Err(String) on parse failure

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let fix_str = "8=FIX.4.4\x019=100\x0135=D\x0149=SENDER\x0156=TARGET\x0155=AAPL\x0154=1\x0110=000\x01";
let msg = FixMessage::from_string(fix_str, parser_id).unwrap();
assert_eq!(msg.msg_type().unwrap(), "D");
assert_eq!(msg.get(55), Some("AAPL".to_string()));

pub fn has_flag(&self, tag: i32) -> bool

Check if a field is set to a boolean flag value (Y or N)

In FIX protocol, boolean flags are typically represented as Y (true) or N (false). This method checks if a field exists and is set to ‘Y’.

§Arguments
  • tag - FIX tag number to check
§Returns

true if field is set to ‘Y’, false otherwise (including when field is empty)

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
msg.set(141, "Y").unwrap(); // ResetSeqNumFlag
assert!(msg.has_flag(141));
msg.set(141, "N").unwrap();
assert!(!msg.has_flag(141));

pub fn is_empty(&self, tag: i32) -> bool

Check if a field is empty (not set)

Returns true if the field is not present in the message. Note that setting a field to an empty string still creates the field, so is_empty will return false.

§Arguments
  • tag - FIX tag number to check
§Returns

true if field doesn’t exist in the message, false if field is present

§Example
use fixantenna_bindings::FixMessage;
let parser_id = 6; // FIX.4.4
let mut msg = FixMessage::new("D", parser_id).unwrap();
assert!(msg.is_empty(55)); // Symbol not set yet
msg.set(55, "AAPL").unwrap();
assert!(!msg.is_empty(55)); // Now it has a value
msg.remove(55);
assert!(msg.is_empty(55)); // Field removed

Trait Implementations§

§

impl Drop for FixMessage

§

fn drop(&mut self)

Executes the destructor for this type. Read more
§

impl Send for FixMessage

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> 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, 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.