Struct hotfix_encoding::decoder::Decoder
source · pub struct Decoder { /* private fields */ }
Expand description
FIX message decoder.
One should create a Decoder
per stream of FIX messages.
Implementations§
source§impl Decoder
impl Decoder
sourcepub fn new(dict: Dictionary) -> Self
pub fn new(dict: Dictionary) -> Self
Creates a new Decoder
for the tag-value format. dict
is used to parse
messages.
sourcepub fn streaming<B>(self, buffer: B) -> DecoderStreaming<B>where
B: Buffer,
pub fn streaming<B>(self, buffer: B) -> DecoderStreaming<B>where B: Buffer,
Adds a [Buffer
] to self
, turning it into a [StreamingDecoder
].
sourcepub fn decode<T>(&mut self, bytes: T) -> Result<Message<'_, T>, DecodeError>where
T: AsRef<[u8]>,
pub fn decode<T>(&mut self, bytes: T) -> Result<Message<'_, T>, DecodeError>where T: AsRef<[u8]>,
Decodes data
and returns an immutable reference to the obtained
message.
Examples
use hotfix_dictionary::{Dictionary};
use hotfix_encoding::fix44;
use hotfix_encoding::config::{Config, GetConfig};
use hotfix_encoding::decoder::Decoder;
use hotfix_encoding::field_access::FieldMap;
let dict = Dictionary::fix44();
let mut decoder = Decoder::new(dict);
decoder.config_mut().separator = b'|';
let data = b"8=FIX.4.4|9=42|35=0|49=A|56=B|34=12|52=20100304-07:59:30|10=185|";
let message = decoder.decode(data).unwrap();
assert_eq!(message.get(fix44::SENDER_COMP_ID), Ok("A"));
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Decoder
impl Send for Decoder
impl Sync for Decoder
impl Unpin for Decoder
impl UnwindSafe for Decoder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more