pub struct RawMessage<'a> { /* private fields */ }Expand description
Zero-copy view into a FIX message buffer.
This struct holds references to the original message buffer, avoiding allocation during parsing. Fields are stored as offset ranges into the buffer.
§Range convention
Every stored range is relative to buffer, not to whatever larger buffer
the message may have been decoded from. A decoder that reads several
messages out of one input must rebase its offsets by the start of the
current message before constructing a RawMessage; RawMessage::new
rejects any range that does not lie within buffer.
Implementations§
Source§impl<'a> RawMessage<'a>
impl<'a> RawMessage<'a>
Sourcepub fn new(
buffer: &'a [u8],
begin_string: Range<usize>,
body: Range<usize>,
msg_type: MsgType,
fields: SmallVec<[FieldRef<'a>; 32]>,
) -> Result<Self, DecodeError>
pub fn new( buffer: &'a [u8], begin_string: Range<usize>, body: Range<usize>, msg_type: MsgType, fields: SmallVec<[FieldRef<'a>; 32]>, ) -> Result<Self, DecodeError>
Creates a new RawMessage from parsed components.
§Arguments
buffer- The complete message bufferbegin_string- Range of the BeginString value, relative tobufferbody- Range of the message body, relative tobuffermsg_type- The parsed message typefields- Parsed field references
§Errors
Returns DecodeError::RangeOutOfBounds if begin_string or body
is inverted or does not lie within buffer. Every offset here derives
from attacker-supplied bytes, so the bounds are checked once at
construction rather than at every accessor.
Sourcepub fn begin_string(&self) -> Result<&'a str, DecodeError>
pub fn begin_string(&self) -> Result<&'a str, DecodeError>
Returns the BeginString value (e.g., “FIX.4.4”).
§Errors
Returns DecodeError::InvalidUtf8 if the BeginString bytes are not
valid UTF-8, or DecodeError::RangeOutOfBounds if the stored range
escapes the buffer. The value is never silently defaulted to "".
Sourcepub fn body(&self) -> Result<&'a [u8], DecodeError>
pub fn body(&self) -> Result<&'a [u8], DecodeError>
Returns the message body bytes (after BodyLength, before the checksum).
§Errors
Returns DecodeError::RangeOutOfBounds if the stored range escapes
the buffer.
Sourcepub fn fields(&self) -> impl Iterator<Item = &FieldRef<'a>>
pub fn fields(&self) -> impl Iterator<Item = &FieldRef<'a>>
Returns an iterator over all fields.
Sourcepub fn field_count(&self) -> usize
pub fn field_count(&self) -> usize
Returns the number of fields in the message.
Sourcepub fn get_field_str(&self, tag: u32) -> Option<&'a str>
pub fn get_field_str(&self, tag: u32) -> Option<&'a str>
Sourcepub fn get_field_as<T: FromStr>(&self, tag: u32) -> Result<T, DecodeError>
pub fn get_field_as<T: FromStr>(&self, tag: u32) -> Result<T, DecodeError>
Sourcepub fn body_range(&self) -> &Range<usize>
pub fn body_range(&self) -> &Range<usize>
Returns the message body range.
Sourcepub fn to_owned(&self) -> OwnedMessage
pub fn to_owned(&self) -> OwnedMessage
Converts this borrowed message to an owned message.
Trait Implementations§
Source§impl<'a> Clone for RawMessage<'a>
impl<'a> Clone for RawMessage<'a>
Source§fn clone(&self) -> RawMessage<'a>
fn clone(&self) -> RawMessage<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more