pub struct FileWatcher { /* private fields */ }Expand description
Watches a file for changes and unblocks the provided blocker when a change occurs.
use std::env::current_dir;
use ed_journals::fs::{auto_detect_journal_path, FileWatcher, SyncBlocker};
let path = current_dir()
.unwrap()
.join("..")
.join("test-files")
.join("journals")
.join("Journal.2000-01-01T100000.01.log");
let blocker = SyncBlocker::new();
let file_watcher = FileWatcher::new(&path, &blocker).unwrap();
blocker.wait().unwrap();
// Something changedKeep in mind that this watcher needs to be kept in scope for as long as you want to receive notifications.
Implementations§
Source§impl FileWatcher
impl FileWatcher
Sourcepub fn new<P: AsRef<Path>>(
path: P,
unblocker: impl Into<Arc<dyn Unblocker>>,
) -> Result<FileWatcher, LogFSError>
pub fn new<P: AsRef<Path>>( path: P, unblocker: impl Into<Arc<dyn Unblocker>>, ) -> Result<FileWatcher, LogFSError>
Creates a new FileWatcher which will watch the provided path for changes.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FileWatcher
impl RefUnwindSafe for FileWatcher
impl Send for FileWatcher
impl Sync for FileWatcher
impl Unpin for FileWatcher
impl UnsafeUnpin for FileWatcher
impl UnwindSafe for FileWatcher
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