Crate skullrump [] [src]

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

Reexports

pub extern crate byteorder;

Enums

StreamFlow

The direction the stream is reading in.

Traits

BinaryChunkStream

A "stream" of incoming binary entries.

BinaryEntry

A single entry to be written to a binary file.