Crate staart

source ·
Expand description

staart is a Rust implementation of a tail-like program

The library exposes public methods to allow other programs to follow a file internally. These methods are exposed on a struct TailedFile.

§Example

use std::thread::sleep;
use std::time::Duration;
use staart::{StaartError, TailedFile};

fn main() -> Result<(), StaartError> {
    let delay = Duration::from_millis(100);
    let args: Vec<String> = std::env::args().collect();
    let path = &args[1].as_str();
    let mut f = TailedFile::new(path)?;
    loop {
       f.read_and(|d| print!("{}", std::str::from_utf8(d).unwrap()))?;
       sleep(delay);
    }
}

Structs§

  • TailedFile tracks the state of a file being followed. It offers methods for updating this state, and printing data to stdout.

Enums§