FileListenerBuilder

Struct FileListenerBuilder 

Source
pub struct FileListenerBuilder { /* private fields */ }
Expand description

Builds a FileListener.

Implementations§

Source§

impl FileListenerBuilder

Source

pub fn new<P: AsRef<Path>>(path: P) -> Self

Creates a new FileListenerBuilder for the specified file path.

Source

pub const fn max_lines(self, max: usize) -> Self

Sets the maximum number of lines the FileListener will keep in its buffer.

Source

pub const fn initial_read_lines(self, lines: usize) -> Self

Sets the number of lines to read from the end of the file on the first tick().

Source

pub fn parser<F>(self, parser: F) -> Self
where F: Fn(String, Option<DateTime<Utc>>) -> (DateTime<Utc>, String) + Send + Sync + 'static,

Sets a custom line parser.

The parser is a closure that takes the read line (String) and the timestamp of the previous line (Option<DateTime<Utc>>), and returns a tuple of (DateTime<Utc>, String). This allows for flexible parsing of custom timestamp formats or assigning timestamps based on other logic.

If not set, a default parser is used which looks for an RFC 3339 timestamp at the beginning of the line.

Source

pub fn build(self) -> Result<FileListener>

Constructs the FileListener.

§Errors

Returns an Error if the path exists but is not a regular file, or if there are permission issues.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.