1 unstable release
Uses old Rust 2015
0.1.0 | Feb 4, 2018 |
---|
#48 in #head
11KB
249 lines
Access this directory at git://len.falken.directory/code/skullrump.git
See https://len.falken.directory/code.xml for other projects.
This is a message left by git://len.falken.directory/code/github-goodbye.git
Own your data, self-host: git://len.falken.directory/code/git-self-host.git
lib.rs
:
skullrump
is a crate to quickly write UNIX-like binary head and tail routines.
In order to make use of it, users implement the BinaryEntry
trait for their types.
File watching is not built in, but can be simulated with the watch
program or similar.
Examples
use std::fs::File;
use std::io::{ Result };
use self::skullrump::byteorder::{ WriteBytesExt, ReadBytesExt };
use self::skullrump::{ BinaryEntry, BinaryChunkStream };
struct ASingleByte(u8);
impl BinaryEntry for ASingleByte {
fn entry_write(data_in: Self, buffer_out: &mut Vec<u8>) -> Result<()> {
buffer_out.write_u8(data_in.0)
}
fn entry_read(file: &mut File) -> Result<Self> {
file
.read_u8()
.and_then(|data| Ok(ASingleByte(data)))
}
fn entry_size() -> i64 {
1
}
}
fn foo(file: &mut File) {
let mut buff:Vec<u8> = vec![];
file.entry_write(&mut buff, ASingleByte(1));
match file.tail::<ASingleByte>(1) {
Ok(_entries) => {}
Err(_) => {}
};
}
Dependencies
~115KB