pub struct Message(/* private fields */);Expand description
Base class for all FIX messages.
Implementations§
Source§impl Message
impl Message
Sourcepub fn new() -> Self
pub fn new() -> Self
Create new empty struct.
Examples found in repository?
62fn parse_send_to(source: &str) -> Result<(Message, SessionId), BadCommand> {
63 // Split command into token
64 let mut tokens = source.split_whitespace();
65 debug_assert_eq!(tokens.next().as_deref(), Some("send_to"));
66
67 let text_msg = tokens.next().ok_or(BadCommand::InvalidArgumentCount {
68 current: 0,
69 expected: 3,
70 })?;
71 let text_sender = tokens.next().ok_or(BadCommand::InvalidArgumentCount {
72 current: 1,
73 expected: 3,
74 })?;
75 let text_target = tokens.next().ok_or(BadCommand::InvalidArgumentCount {
76 current: 2,
77 expected: 3,
78 })?;
79
80 // Build message from 1st data token
81 let mut msg = Message::new();
82 for field in text_msg.split('|') {
83 let mut field_tokens = field.splitn(2, '=');
84
85 let tag = field_tokens
86 .next()
87 .ok_or(BadCommand::InvalidArgument("Invalid tag"))?
88 .parse()
89 .ok()
90 .ok_or(BadCommand::InvalidArgument("Invalid tag number"))?;
91
92 let value = field_tokens
93 .next()
94 .ok_or(BadCommand::InvalidArgument("Invalid value"))?;
95
96 msg.set_field(tag, value)
97 .ok()
98 .expect("Fail to set msg tag=value");
99 }
100
101 // Build session ID from 2nd data token
102 let session_id = SessionId::try_new("FIX.4.4", text_sender, text_target, "")
103 .expect("Fail to allocate new session ID");
104
105 Ok((msg, session_id))
106}Sourcepub fn try_from_text(text: &str) -> Result<Self, QuickFixError>
pub fn try_from_text(text: &str) -> Result<Self, QuickFixError>
Try create new struct from raw text message.
Sourcepub fn to_fix_string(&self) -> Result<String, QuickFixError>
pub fn to_fix_string(&self) -> Result<String, QuickFixError>
Try reading underlying struct buffer as a FIX string.
§Performances
Do not use this method in latency sensitive code.
String will be generated twice in C++ code:
- Once for getting a safe buffer length.
- Then to copy buffer to rust “memory”.
Sourcepub fn clone_header(&self) -> Header
pub fn clone_header(&self) -> Header
Sourcepub fn with_header<T, F>(&self, f: F) -> T
pub fn with_header<T, F>(&self, f: F) -> T
Read struct header part.
§Panic
When struct pointer cannot be read from FIX::Message. This is
something that could not be theoretically possible.
Sourcepub fn with_header_mut<T, F>(&mut self, f: F) -> T
pub fn with_header_mut<T, F>(&mut self, f: F) -> T
Read or write struct header part.
§Panic
When struct pointer cannot be read from FIX::Message. This is
something that could not be theoretically possible.
Sourcepub fn clone_trailer(&self) -> Trailer
pub fn clone_trailer(&self) -> Trailer
Sourcepub fn with_trailer<T, F>(&self, f: F) -> T
pub fn with_trailer<T, F>(&self, f: F) -> T
Read struct trailer part.
§Panic
When struct pointer cannot be read from FIX::Message. This is
something that could not be theoretically possible.
Sourcepub fn with_trailer_mut<T, F>(&mut self, f: F) -> T
pub fn with_trailer_mut<T, F>(&mut self, f: F) -> T
Read or write struct trailer part.
§Panic
When struct pointer cannot be read from FIX::Message. This is
something that could not be theoretically possible.
Sourcepub fn with_group<T, F>(&self, index: i32, tag: i32, f: F) -> Option<T>
pub fn with_group<T, F>(&self, index: i32, tag: i32, f: F) -> Option<T>
Read struct group part for a given tag and group index.