skullrump 0.1.0

Quickly write UNIX-like binary head and tail routines.
Documentation
  • Coverage
  • 84.62%
    11 out of 13 items documented1 out of 1 items with examples
  • Size
  • Source code size: 10.22 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.65 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • lf94/skullrump
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • lf94

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(_)      => {}
  };
}