|Branch|Status|
|------|------|
|master||
Rust Byte Swap lib.
Swap bytes using patterns and masks.
bswp
requires Rust 1.40.0.
```rust use bswp::pattern::{Pattern, Predicate, swap_iter};
let pattern = Pattern::new(0x42).withmask(0xFF); // replace byte by 0x42 let predicate = Predicate::new().withperiodicity(2).with_offset(1); // replace odd bytes let swaps = &[(pattern, predicate)];
let source: [u8; 4] = [0x41, 0x41, 0x41, 0x41];
let swapped = swapiter(&source, swaps); // iterator on result
let swapped: Vec
```rust use std::io::Cursor; use bswp::pattern::{Pattern, Predicate}; use bswp::io::swap_io;
// in memory reader (implements Read
)
let mut reader: CursorWrite
)
let mut writer: Cursor
let swaps: &[(Pattern, Predicate)] = &[(Pattern::new(0x42).withmask(0xFF), Predicate::new().withperiodicity(2).withoffset(0))]; let swap = swapio(&mut reader, &mut writer, swaps); assert!(swap.isok()); asserteq!(swap.unwrap(), 4); // 4 bytes written asserteq!(writer.intoinner(), vec![0x42, 0x42, 0x42, 0x44]) ```
Please see the CHANGELOG for a release history.