pub struct FixMessage { /* private fields */ }
Expand description
This is the interface you interact with.
The internal message is represented as follows:
ⓘ
FixMessage := FixComponent
FixComponent := FixEntity*
FixEntity := Field | Group
Field := (tag: i32, value: String)
Group := FixComponent*
Implementations§
Source§impl FixMessage
impl FixMessage
Sourcepub fn from_tag_value(input_message: &str) -> Option<FixMessage>
pub fn from_tag_value(input_message: &str) -> Option<FixMessage>
Creates a FixMessage from an input string encoded in FIX Tag=Value (classic FIX).
§Examples
let input = "Recv | 8=FIX.4.4 | 555=2 | 600=CGY | 604=2 | 605=F7 | 605=CGYU0 | 600=CGY | 10=209";
println!("{}", fixparser::FixMessage::from_tag_value(&input).unwrap().to_json());
Examples found in repository?
examples/from-stdin.rs (line 11)
3fn main() -> io::Result<()> {
4 println!("Give me a tag-value FIX message, and I will give you a JSON.");
5 println!("Do you need help? You can try this one: 8=FIX.4.2 | 10=209");
6
7 let stdin = io::stdin();
8 let handle = stdin.lock();
9
10 for line in handle.lines() {
11 if let Some(fix_message) = fixparser::FixMessage::from_tag_value(&line?) {
12 println!("{}", fix_message.to_json());
13 } else {
14 println!("Are your sure you gave me a valid FIX message?");
15 }
16 }
17
18 Ok(())
19}
Sourcepub fn to_json(&self) -> Value
pub fn to_json(&self) -> Value
Get a representation of the message in json string format.
§Examples
// this input has the non-printable character 0x01 as the separator of the fields
let input = "8=FIX.4.4555=2600=CGY604=2605=F7605=CGYU0600=CGY10=209";
println!("{}", fixparser::FixMessage::from_tag_value(&input).unwrap().to_json());
ⓘ
{"8":"FIX.4.4","555":[{"600":"CGY","604":[{"605":"F7"},{"605":"CGYU0"}]},{"600":"CGY"}],"10":"209"}
Examples found in repository?
examples/from-stdin.rs (line 12)
3fn main() -> io::Result<()> {
4 println!("Give me a tag-value FIX message, and I will give you a JSON.");
5 println!("Do you need help? You can try this one: 8=FIX.4.2 | 10=209");
6
7 let stdin = io::stdin();
8 let handle = stdin.lock();
9
10 for line in handle.lines() {
11 if let Some(fix_message) = fixparser::FixMessage::from_tag_value(&line?) {
12 println!("{}", fix_message.to_json());
13 } else {
14 println!("Are your sure you gave me a valid FIX message?");
15 }
16 }
17
18 Ok(())
19}
Auto Trait Implementations§
impl Freeze for FixMessage
impl RefUnwindSafe for FixMessage
impl Send for FixMessage
impl Sync for FixMessage
impl Unpin for FixMessage
impl UnwindSafe for FixMessage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more