1 unstable release
Uses old Rust 2015
0.0.1 | Dec 24, 2015 |
---|
#43 in #fix
52 downloads per month
9KB
101 lines
fix_checksum
FIX message checksum validator/generator RUST library
lib.rs
:
The fix_checksum
crate provides functions that
validate FIX message checksum and generate checksum of FIX message.
Examples
use fix_checksum::{validate, generate};
use fix_checksum::FIXChecksumValidatorError::InvalidEmptyMessage;
// Validator
assert_eq!(validate("").unwrap_err(), InvalidEmptyMessage);
let message_parts: Vec<&str> = vec!["8=FIX.4.2", "9=73", "35=0", "49=BRKR",
"56=INVMGR", "34=235", "52=19980604-07:58:28", "112=19980604-07:58:28", "10=236"];
let mut message: String = message_parts
.iter()
.fold(String::new(), |msg, msg_part| msg.to_string() + msg_part + "\x01");
assert_eq!(validate(&message).unwrap(), true);
// Generator
message = message_parts
.iter()
.take(8)
.fold(String::new(), |msg, msg_part| msg.to_string() + msg_part + "\x01");
assert_eq!("236", generate(&message));