Struct Message

Source
pub struct Message(/* private fields */);
Expand description

Base class for all FIX messages.

Implementations§

Source§

impl Message

Source

pub fn new() -> Self

Create new empty struct.

Examples found in repository?
examples/fix_repl/command_parser.rs (line 81)
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}
Source

pub fn try_from_text(text: &str) -> Result<Self, QuickFixError>

Try create new struct from raw text message.

Source

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”.
Source

pub fn clone_header(&self) -> Header

Clone struct header part.

§Panic

When memory allocation fail in C++ library.

Source

pub fn with_header<T, F>(&self, f: F) -> T
where F: FnOnce(&Header) -> T,

Read struct header part.

§Panic

When struct pointer cannot be read from FIX::Message. This is something that could not be theoretically possible.

Source

pub fn with_header_mut<T, F>(&mut self, f: F) -> T
where F: FnOnce(&mut Header) -> 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.

Source

pub fn clone_trailer(&self) -> Trailer

Clone struct trailer part.

§Panic

When memory allocation fail in C++ library.

Source

pub fn with_trailer<T, F>(&self, f: F) -> T
where F: FnOnce(&Trailer) -> T,

Read struct trailer part.

§Panic

When struct pointer cannot be read from FIX::Message. This is something that could not be theoretically possible.

Source

pub fn with_trailer_mut<T, F>(&mut self, f: F) -> T
where F: FnOnce(&mut Trailer) -> 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.

Source

pub fn with_group<T, F>(&self, index: i32, tag: i32, f: F) -> Option<T>
where F: FnOnce(&Group) -> T,

Read struct group part for a given tag and group index.

Source

pub fn with_group_mut<T, F>(&mut self, index: i32, tag: i32, f: F) -> Option<T>
where F: FnOnce(&mut Group) -> T,

Read or write struct group part for a given tag and group index.

Trait Implementations§

Source§

impl Clone for Message

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Message

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Message

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for Message

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl FieldMap for Message

Source§

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

Get field value from its tag number.
Source§

fn set_field<V: IntoFixValue>( &mut self, tag: i32, value: V, ) -> Result<(), QuickFixError>

Set field value for a given tag number.
Source§

fn remove_field(&mut self, tag: i32) -> Result<(), QuickFixError>

Remove a field from collection.
Source§

fn add_group(&mut self, group: &Group) -> Result<(), QuickFixError>

Add a new group to storage and update count.
Source§

fn clone_group(&self, index: i32, tag: i32) -> Option<Group>

Clone group part for a given tag and group index.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.