Struct FixMessage

Source
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

Source

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}
Source

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§

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.