1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//! Triggers

use std::error::Error;
use std::fmt;

use append::rolling_file::LogFile;
#[cfg(feature = "file")]
use file::Deserializable;

#[cfg(feature = "size_trigger")]
pub mod size;

/// A trait which identifies if the active log file should be rolled over.
pub trait Trigger: fmt::Debug + Send + Sync + 'static {
    /// Determines if the active log file should be rolled over.
    fn trigger(&self, file: &LogFile) -> Result<bool, Box<Error + Sync + Send>>;
}

#[cfg(feature = "file")]
impl Deserializable for Trigger {
    fn name() -> &'static str {
        "trigger"
    }
}