src/tail/engine/mod.rs

//! Platform-specific tailing engines.
//!
//! On Linux we use `inotify` via the `notify` crate. On macOS we use `kqueue`.
//! Everywhere else we fall back to a 200ms polling loop. The public API is
//! identical: a `run` function that takes a list of watched paths and a
//! callback that receives change events.

pub mod poll;

#[cfg(target_os = "linux")]
pub mod inotify;

#[cfg(target_os = "macos")]
pub mod kqueue;

use std::path::PathBuf;

/// Event emitted by the underlying engine.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Event {
    Grew(PathBuf),
    Shrunk(PathBuf),
    Rotated(PathBuf),
    Gone(PathBuf),
}

/// Select the default engine at compile time.
pub fn platform_default() -> &'static str {
    #[cfg(target_os = "linux")]
    {
        "inotify"
    }
    #[cfg(target_os = "macos")]
    {
        "kqueue"
    }
    #[cfg(not(any(target_os = "linux", target_os = "macos")))]
    {
        "poll"
    }
}