pub trait FieldMap<F> {
type Group: RepeatingGroup<Entry = Self>;
// Required methods
fn get_raw(&self, field: F) -> Option<&[u8]>;
fn group(
&self,
field: F,
) -> Result<Self::Group, FieldValueError<<usize as FieldType<'_>>::Error>>;
// Provided methods
fn group_opt(
&self,
field: F,
) -> Result<Option<Self::Group>, <usize as FieldType<'_>>::Error> { ... }
fn get<'a, V>(&'a self, field: F) -> Result<V, FieldValueError<V::Error>>
where V: FieldType<'a> { ... }
fn get_lossy<'a, V>(
&'a self,
field: F,
) -> Result<V, FieldValueError<V::Error>>
where V: FieldType<'a> { ... }
fn get_opt<'a, V>(&'a self, field: F) -> Result<Option<V>, V::Error>
where V: FieldType<'a> { ... }
fn get_lossy_opt<'a, V>(&'a self, field: F) -> Result<Option<V>, V::Error>
where V: FieldType<'a> { ... }
}
Expand description
Provides random (i.e. non-sequential) access to FIX fields and groups within messages.
§Methods
FieldMap
provides two kinds of methods:
-
Group getters:
FieldMap::group
andFieldMap::group_opt
. -
Field getters:
FieldMap::get_raw
,FieldMap::get
, etc..
The most basic form of field access is done via
FieldMap::get_raw
, which performs no deserialization at all: it
simply returns the bytes contents associated with a FIX field, if found.
Building upon FieldMap::get_raw
and FieldType
, the other
field access methods all provide some utility deserialization logic. These
methods all have the get_
prefix, with the following considerations:
get_lossy
methods perform “lossy” deserialization viaFieldType::deserialize_lossy
. Unlike lossless deserialization, these methods may skip some error checking logic and thus prove to be faster. Memory-safety is still guaranteed, but malformed FIX fields won’t be detected 100% of the time.get_opt
methods work exactly like their non-_opt
counterparties, but they have a different return type: instead of returning [Err(None)
] for missing fields, these methods returnNone
for missing fields and [Some(Ok(field))
] for existing fields.
§Type parameters
This trait is generic over a type F
, which must univocally identify FIX
fields (besides FIX repeating groups, which allow repetitions).
Required Associated Types§
Sourcetype Group: RepeatingGroup<Entry = Self>
type Group: RepeatingGroup<Entry = Self>
The type returned by FieldMap::group
and
FieldMap::group_opt
.
Required Methods§
Provided Methods§
Sourcefn group_opt(
&self,
field: F,
) -> Result<Option<Self::Group>, <usize as FieldType<'_>>::Error>
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.
Sourcefn get<'a, V>(&'a self, field: F) -> Result<V, FieldValueError<V::Error>>where
V: FieldType<'a>,
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.
Sourcefn get_lossy<'a, V>(&'a self, field: F) -> Result<V, FieldValueError<V::Error>>where
V: FieldType<'a>,
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.
Sourcefn get_opt<'a, V>(&'a self, field: F) -> Result<Option<V>, V::Error>where
V: FieldType<'a>,
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.
Sourcefn get_lossy_opt<'a, V>(&'a self, field: F) -> Result<Option<V>, V::Error>where
V: FieldType<'a>,
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.