pub struct DatabaseWatcher<'a> { /* private fields */ }Expand description
Database watcher service that monitors file changes and updates the database.
Implementations§
Source§impl<'a> DatabaseWatcher<'a>
impl<'a> DatabaseWatcher<'a>
pub fn new(database: Database<'a>) -> Self
pub fn watch(&mut self, options: WatchOptions) -> Result<(), DatabaseError>
Sourcepub fn is_watching(&self) -> bool
pub fn is_watching(&self) -> bool
Checks if the watcher is currently active.
Sourcepub fn wait(&mut self) -> Result<Vec<FileId>, DatabaseError>
pub fn wait(&mut self) -> Result<Vec<FileId>, DatabaseError>
Waits for file changes and updates the database.
This method blocks until file changes are detected, then updates the database in place and returns the IDs of changed files.
§Returns
Ok(file_ids)- The IDs of files that were changed (empty if no changes)Err(DatabaseError::WatcherNotActive)- If the watcher is not currently watchingErr(e)- If updating the database failed
Sourcepub fn read_only_database(&self) -> ReadDatabase
pub fn read_only_database(&self) -> ReadDatabase
Returns a reference to the database.
Sourcepub fn database_mut(&mut self) -> &mut Database<'a>
pub fn database_mut(&mut self) -> &mut Database<'a>
Returns a mutable reference to the database.
Sourcepub fn with_database_mut<F, R>(&mut self, f: F) -> R
pub fn with_database_mut<F, R>(&mut self, f: F) -> R
Provides temporary mutable access to the database through a closure.
This method helps Rust’s borrow checker understand that the mutable borrow of the database is scoped to just the closure execution, allowing the watcher to be used again after the closure returns.
The closure is bounded with for<’x> to explicitly show that the database reference lifetime is scoped to the closure execution only.
Sourcepub fn into_database(self) -> Database<'a>
pub fn into_database(self) -> Database<'a>
Consumes the watcher and returns the database.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for DatabaseWatcher<'a>
impl<'a> RefUnwindSafe for DatabaseWatcher<'a>
impl<'a> Send for DatabaseWatcher<'a>
impl<'a> !Sync for DatabaseWatcher<'a>
impl<'a> Unpin for DatabaseWatcher<'a>
impl<'a> UnwindSafe for DatabaseWatcher<'a>
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more