Struct tantivy::directory::ManagedDirectory
source · pub struct ManagedDirectory { /* private fields */ }
Expand description
Wrapper of directories that keeps track of files created by Tantivy.
A managed directory is just a wrapper of a directory that keeps a (persisted) list of the files that have been created (and not deleted) by tantivy so far.
Thanks to this list, it implements a garbage_collect
method
that removes the files that were created by tantivy and are not
useful anymore.
Implementations§
source§impl ManagedDirectory
impl ManagedDirectory
sourcepub fn wrap(directory: Box<dyn Directory>) -> Result<ManagedDirectory>
pub fn wrap(directory: Box<dyn Directory>) -> Result<ManagedDirectory>
Wraps a directory as managed directory.
sourcepub fn garbage_collect<L: FnOnce() -> HashSet<PathBuf>>(
&mut self,
get_living_files: L
) -> Result<GarbageCollectionResult>
pub fn garbage_collect<L: FnOnce() -> HashSet<PathBuf>>( &mut self, get_living_files: L ) -> Result<GarbageCollectionResult>
Garbage collect unused files.
Removes the files that were created by tantivy
and are not
used by any segment anymore.
living_files
- List of files that are still used by the index.
The use a callback ensures that the list of living_files is computed while we hold the lock on meta.
This method does not panick nor returns errors. If a file cannot be deleted (for permission reasons for instance) an error is simply logged, and the file remains in the list of managed files.
sourcepub fn validate_checksum(&self, path: &Path) -> Result<bool, OpenReadError>
pub fn validate_checksum(&self, path: &Path) -> Result<bool, OpenReadError>
Verify checksum of a managed file
sourcepub fn list_managed_files(&self) -> HashSet<PathBuf>
pub fn list_managed_files(&self) -> HashSet<PathBuf>
List all managed files
Trait Implementations§
source§impl Clone for ManagedDirectory
impl Clone for ManagedDirectory
source§fn clone(&self) -> ManagedDirectory
fn clone(&self) -> ManagedDirectory
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ManagedDirectory
impl Debug for ManagedDirectory
source§impl Directory for ManagedDirectory
impl Directory for ManagedDirectory
source§fn get_file_handle(
&self,
path: &Path
) -> Result<Arc<dyn FileHandle>, OpenReadError>
fn get_file_handle( &self, path: &Path ) -> Result<Arc<dyn FileHandle>, OpenReadError>
FileHandle
. Read moresource§fn open_read(&self, path: &Path) -> Result<FileSlice, OpenReadError>
fn open_read(&self, path: &Path) -> Result<FileSlice, OpenReadError>
source§fn open_write(&self, path: &Path) -> Result<WritePtr, OpenWriteError>
fn open_write(&self, path: &Path) -> Result<WritePtr, OpenWriteError>
source§fn atomic_write(&self, path: &Path, data: &[u8]) -> Result<()>
fn atomic_write(&self, path: &Path, data: &[u8]) -> Result<()>
source§fn atomic_read(&self, path: &Path) -> Result<Vec<u8>, OpenReadError>
fn atomic_read(&self, path: &Path) -> Result<Vec<u8>, OpenReadError>
Directory::atomic_write()
. Read moresource§fn exists(&self, path: &Path) -> Result<bool, OpenReadError>
fn exists(&self, path: &Path) -> Result<bool, OpenReadError>
source§fn acquire_lock(&self, lock: &Lock) -> Result<DirectoryLock, LockError>
fn acquire_lock(&self, lock: &Lock) -> Result<DirectoryLock, LockError>
source§fn watch(&self, watch_callback: WatchCallback) -> Result<WatchHandle>
fn watch(&self, watch_callback: WatchCallback) -> Result<WatchHandle>
meta.json
using the Directory::atomic_write()
API is detected. Read moreAuto Trait Implementations§
impl Freeze for ManagedDirectory
impl !RefUnwindSafe for ManagedDirectory
impl Send for ManagedDirectory
impl Sync for ManagedDirectory
impl Unpin for ManagedDirectory
impl !UnwindSafe for ManagedDirectory
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
source§impl<T> DirectoryClone for T
impl<T> DirectoryClone for T
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.