Struct Message

Source
pub struct Message<'a, T> { /* private fields */ }
Expand description

A FIX message returned by Decoder or [DecoderStreaming].

Implementations§

Source§

impl<'a, T> Message<'a, T>

Source

pub fn fields(&'a self) -> Fields<'a, T>

Returns an Iterator over all fields in self, in sequential order starting from the very first field.

§Examples
use hotfix_encoding::config::{Config, GetConfig};
use hotfix_encoding::decoder::{Decoder};
use hotfix_dictionary::{Dictionary, TagU32};

const DATA: &[u8] = b"8=FIX.4.4|9=42|35=0|49=A|56=B|34=12|52=20100304-07:59:30|10=185|";

let mut decoder = Decoder::new(Dictionary::fix44());
decoder.config_mut().separator = b'|';

let message = decoder.decode(DATA).unwrap();
let first_field = message.fields().next();

assert_eq!(first_field, Some((TagU32::new(8).unwrap(), b"FIX.4.4" as &[u8])));
Source

pub fn as_bytes(&self) -> &[u8]

Returns the underlying byte contents of self.

§Examples
use hotfix_encoding::config::{Config, GetConfig};
use hotfix_encoding::decoder::{Decoder};
use hotfix_dictionary::{Dictionary, TagU32};

const DATA: &[u8] = b"8=FIX.4.4|9=42|35=0|49=A|56=B|34=12|52=20100304-07:59:30|10=185|";

let mut decoder = Decoder::new(Dictionary::fix44());
decoder.config_mut().separator = b'|';

let message = decoder.decode(DATA).unwrap();
assert_eq!(message.as_bytes(), DATA);
Source

pub fn len(&self) -> usize

Returns the number of FIX tags contained in self.

§Examples
use hotfix_encoding::config::{Config, GetConfig};
use hotfix_encoding::decoder::{Decoder};
use hotfix_dictionary::{Dictionary, TagU32};

const DATA: &[u8] = b"8=FIX.4.4|9=42|35=0|49=A|56=B|34=12|52=20100304-07:59:30|10=185|";

let mut decoder = Decoder::new(Dictionary::fix44());
decoder.config_mut().separator = b'|';

let message = decoder.decode(DATA).unwrap();
assert_eq!(message.len(), message.fields().count());
Source

pub fn is_empty(&self) -> bool

Trait Implementations§

Source§

impl<'a, T: Clone> Clone for Message<'a, T>

Source§

fn clone(&self) -> Message<'a, T>

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<'a, T: Debug> Debug for Message<'a, T>

Source§

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

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

impl<'a, F, T> FieldMap<&F> for Message<'a, T>
where F: IsFieldDefinition, T: AsRef<[u8]> + Clone,

Source§

type Group = MessageGroup<'a, T>

The type returned by FieldMap::group and FieldMap::group_opt.
Source§

fn get_raw(&self, field: &F) -> Option<&[u8]>

Looks for a field within self and then returns its raw byte contents, if it exists.
Source§

fn group( &self, field: &F, ) -> Result<Self::Group, FieldValueError<<usize as FieldType<'_>>::Error>>

Looks for a group that starts with field within self.
Source§

fn group_opt( &self, field: F, ) -> Result<Option<Self::Group>, <usize as FieldType<'_>>::Error>

Like FieldMap::group, but doesn’t return an Err if the group is missing.
Source§

fn get<'a, V>(&'a self, field: F) -> Result<V, FieldValueError<V::Error>>
where V: FieldType<'a>,

Looks for a field within self and then decodes its raw byte contents via FieldType::deserialize, if found.
Source§

fn get_lossy<'a, V>(&'a self, field: F) -> Result<V, FieldValueError<V::Error>>
where V: FieldType<'a>,

Like FieldMap::get, but with lossy deserialization.
Source§

fn get_opt<'a, V>(&'a self, field: F) -> Result<Option<V>, V::Error>
where V: FieldType<'a>,

Like FieldMap::get, but doesn’t return an Err if field is missing.
Source§

fn get_lossy_opt<'a, V>(&'a self, field: F) -> Result<Option<V>, V::Error>
where V: FieldType<'a>,

Like FieldMap::get_opt, but with lossy deserialization.
Source§

impl<'a, T> FieldMap<u32> for Message<'a, T>
where T: AsRef<[u8]> + Clone,

Source§

type Group = MessageGroup<'a, T>

The type returned by FieldMap::group and FieldMap::group_opt.
Source§

fn get_raw(&self, tag: u32) -> Option<&[u8]>

Looks for a field within self and then returns its raw byte contents, if it exists.
Source§

fn group( &self, tag: u32, ) -> Result<Self::Group, FieldValueError<<usize as FieldType<'_>>::Error>>

Looks for a group that starts with field within self.
Source§

fn group_opt( &self, field: F, ) -> Result<Option<Self::Group>, <usize as FieldType<'_>>::Error>

Like FieldMap::group, but doesn’t return an Err if the group is missing.
Source§

fn get<'a, V>(&'a self, field: F) -> Result<V, FieldValueError<V::Error>>
where V: FieldType<'a>,

Looks for a field within self and then decodes its raw byte contents via FieldType::deserialize, if found.
Source§

fn get_lossy<'a, V>(&'a self, field: F) -> Result<V, FieldValueError<V::Error>>
where V: FieldType<'a>,

Like FieldMap::get, but with lossy deserialization.
Source§

fn get_opt<'a, V>(&'a self, field: F) -> Result<Option<V>, V::Error>
where V: FieldType<'a>,

Like FieldMap::get, but doesn’t return an Err if field is missing.
Source§

fn get_lossy_opt<'a, V>(&'a self, field: F) -> Result<Option<V>, V::Error>
where V: FieldType<'a>,

Like FieldMap::get_opt, but with lossy deserialization.
Source§

impl<'a, T> PartialEq for Message<'a, T>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, T: Copy> Copy for Message<'a, T>

Source§

impl<'a, T> Eq for Message<'a, T>

Auto Trait Implementations§

§

impl<'a, T> Freeze for Message<'a, T>

§

impl<'a, T> RefUnwindSafe for Message<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for Message<'a, T>
where T: Send,

§

impl<'a, T> Sync for Message<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for Message<'a, T>
where T: Unpin,

§

impl<'a, T> UnwindSafe for Message<'a, T>
where T: UnwindSafe,

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.