hdlc
hdlc
Rust implementation of a High-level Data Link Control (HDLC) library with support of the IEEE standard.
Usage
Add hdlc
to Cargo.toml
[]
= "^0.2.1"
or
[]
= "https://github.com/CLomanno/hdlc"
Add this to crate root
extern crate hdlc;
Encode packet
extern crate hdlc;
use ;
// Set up your vector of bytes and generate your Special Characters
let msg: = vec!;
let cmp: = vec!;
// Encode your message
let result = encode;
assert!;
assert_eq!;
Custom Special Characters
extern crate hdlc;
use ;
// Set up your vector of bytes and generate your Special Characters
let msg: = vec!;
let cmp: = vec!;
let chars = new;
// Encode your message
let result = encode;
assert!;
assert_eq!
Decode packet
extern crate hdlc;
use ;
// Set up your vector of bytes and generate your Special Characters
let msg: = vec!;
let cmp: = vec!;
// Decode your message
let result = decode;
assert!;
assert_eq!;
Decode slice packet
extern crate hdlc;
use ;
// Set up your mutable slice of bytes and generate your Special Characters
let chars = default;
let mut msg = ;
let cmp = ;
// Decode your slice
let result = decode_slice;
assert!;
assert_eq!;
Benchmark
Bencher is currently not available in Rust stable releases.
cargo bench
with 2.2 GHz Intel Core i7 results ~430MB/s throughput.
cargo bench
Running target\release\deps\bench-8475e9ff4a76b8c6.exe
running 4 tests
test bench_decode_megabyte ... bench: 2,068,254 ns/iter
test bench_decode_special_chars_2_megabytes ... bench: 5,586,588 ns/iter
test bench_encode_megabyte ... bench: 2,415,257 ns/iter
test bench_encode_special_chars_megabyte ... bench: 5,715,299 ns/iter
test result: ok. 0 passed; 0 failed; 0 ignored; 4 measured; 0 filtered out
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.