pub struct FileListener { /* private fields */ }Expand description
A listener that monitors a file for changes and captures new lines.
Use tick() to poll for changes.
Implementations§
Source§impl FileListener
impl FileListener
Sourcepub fn builder<P: AsRef<Path>>(path: P) -> FileListenerBuilder
pub fn builder<P: AsRef<Path>>(path: P) -> FileListenerBuilder
Creates a new FileListenerBuilder for the given file path.
Sourcepub fn tick(&mut self) -> Result<()>
pub fn tick(&mut self) -> Result<()>
Checks the file for changes and updates the internal line buffer.
This method handles:
- Connecting to the file if it appears.
- Backfilling lines on the first connection.
- Detecting truncation or modification and resetting if necessary.
- Appending new lines as they are written.
§Errors
Returns an [Error] if filesystem operations fail (other than NotFound, which is handled gracefully).
Sourcepub const fn lines(&self) -> &VecDeque<(DateTime<Utc>, String)>
pub const fn lines(&self) -> &VecDeque<(DateTime<Utc>, String)>
Returns an immutable reference to the internal buffer of lines.
Auto Trait Implementations§
impl Freeze for FileListener
impl !RefUnwindSafe for FileListener
impl Send for FileListener
impl Sync for FileListener
impl Unpin for FileListener
impl !UnwindSafe for FileListener
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more