| Crates.io | split_by |
| lib.rs | split_by |
| version | 0.2.2 |
| created_at | 2016-08-30 14:45:03.320225+00 |
| updated_at | 2018-04-11 23:03:17.498892+00 |
| description | Split anything implementing Read trait by multiple sequences of bytes |
| homepage | |
| repository | https://github.com/jsen-/split_by |
| max_upload_size | |
| id | 6184 |
| size | 22,327 |
Split anything implementing Read trait by multiple sequences of bytes
Add this to Cargo.toml, under [dependencies]:
split_by = "0.2"
extern crate split_by;
use split_by::{AcAutomaton, SplitBy}
use std::fs::File;
fn main() {
for section in File::open("path/to/file").unwrap().split_by(&AcAutomaton::new(vec!["<some pattern>"])) {
let bytes = section.expect("read error occurred");
// do something with the bytes found between patterns
}
}