pub struct DirectoryIndex { /* private fields */ }Expand description
A struct representing the directory index, which is a map of paths to their corresponding
DirectoryIndexEntry objects. The index is stored on disk in a file specified by the user (or
a default location see DEFAULT_INDEX_FILE_NAME).
Implementations§
Source§impl DirectoryIndex
impl DirectoryIndex
Sourcepub fn try_from(path: PathBuf) -> Result<Self>
pub fn try_from(path: PathBuf) -> Result<Self>
Reads the index from disk, if it doesn’t exist, creates a new one
Sourcepub fn push(&mut self, path: PathBuf) -> Result<()>
pub fn push(&mut self, path: PathBuf) -> Result<()>
Pushes a new path to the index and saves it to disk. If the path doesn’t exist it’s a no-op. If you push the same path multiple times, it will update the rank and last accessed time.
Sourcepub fn z(&mut self, queries: Vec<String>) -> Result<Option<PathBuf>>
pub fn z(&mut self, queries: Vec<String>) -> Result<Option<PathBuf>>
Finds the top-ranked directory matching the query.
If a non-existing path is found as a match, it will be removed from the index and the next match will be returned until the index is exhausted. The index will be updated if a removal occurs.
The inner workings of this algo was heavily inspured by `rupa/z: https://github.com/rupa/z
Sourcepub fn get_all_entries_ordered_by_rank(&self) -> Vec<PathBuf>
pub fn get_all_entries_ordered_by_rank(&self) -> Vec<PathBuf>
Returns all entries in the index ordered by their frecent score.
Trait Implementations§
Source§impl Debug for DirectoryIndex
impl Debug for DirectoryIndex
Source§impl Default for DirectoryIndex
impl Default for DirectoryIndex
Source§fn default() -> DirectoryIndex
fn default() -> DirectoryIndex
Auto Trait Implementations§
impl Freeze for DirectoryIndex
impl RefUnwindSafe for DirectoryIndex
impl Send for DirectoryIndex
impl Sync for DirectoryIndex
impl Unpin for DirectoryIndex
impl UnwindSafe for DirectoryIndex
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> 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