pub struct SqliteIndex { /* private fields */ }Expand description
SQLite-based file index
Implementations§
Source§impl SqliteIndex
impl SqliteIndex
Sourcepub async fn load(db_path: PathBuf) -> Result<Self>
pub async fn load(db_path: PathBuf) -> Result<Self>
Load index from existing database (alias for new)
Sourcepub async fn get(
&self,
id: &str,
include_deleted: bool,
) -> Result<Option<FileIndexEntry>>
pub async fn get( &self, id: &str, include_deleted: bool, ) -> Result<Option<FileIndexEntry>>
Get an entry by ID
§Arguments
id- The file IDinclude_deleted- If true, include soft-deleted files
Sourcepub async fn soft_delete(
&self,
id: &str,
deleted_by: Option<&str>,
) -> Result<bool>
pub async fn soft_delete( &self, id: &str, deleted_by: Option<&str>, ) -> Result<bool>
Soft delete a file by ID
Marks the file as deleted but does not remove it physically. The file can be restored until the retention period expires.
Sourcepub async fn restore(&self, id: &str) -> Result<bool>
pub async fn restore(&self, id: &str) -> Result<bool>
Restore a soft-deleted file
Clears the deleted_at timestamp, making the file accessible again.
Sourcepub async fn list_deleted(&self) -> Result<Vec<FileIndexEntry>>
pub async fn list_deleted(&self) -> Result<Vec<FileIndexEntry>>
List all soft-deleted files
Sourcepub async fn get_expired_deletions(
&self,
retention_days: u32,
) -> Result<Vec<FileIndexEntry>>
pub async fn get_expired_deletions( &self, retention_days: u32, ) -> Result<Vec<FileIndexEntry>>
Get soft-deleted files that are ready for permanent deletion
§Arguments
retention_days- Files deleted more than this many days ago
Sourcepub async fn hard_delete(&self, id: &str) -> Result<Option<FileIndexEntry>>
pub async fn hard_delete(&self, id: &str) -> Result<Option<FileIndexEntry>>
Hard delete a file (physical removal from database)
Use with caution - this permanently removes the index entry. The actual file data should be deleted separately.
Sourcepub async fn insert(&self, entry: FileIndexEntry) -> Result<()>
pub async fn insert(&self, entry: FileIndexEntry) -> Result<()>
Insert or update an entry
Sourcepub async fn remove(&self, id: &str) -> Result<Option<FileIndexEntry>>
pub async fn remove(&self, id: &str) -> Result<Option<FileIndexEntry>>
Remove an entry by ID
This physically removes the entry from the database.
Note: For soft delete, use soft_delete() instead.
Sourcepub async fn get_candidates_for_cleanup(
&self,
threshold: i32,
max_age_days: u32,
) -> Result<Vec<FileIndexEntry>>
pub async fn get_candidates_for_cleanup( &self, threshold: i32, max_age_days: u32, ) -> Result<Vec<FileIndexEntry>>
Get entries suitable for cleanup
Sourcepub async fn entries(&self) -> Result<Vec<FileIndexEntry>>
pub async fn entries(&self) -> Result<Vec<FileIndexEntry>>
Get all entries (use sparingly with large datasets)
Sourcepub async fn stats(&self) -> Result<IndexStats>
pub async fn stats(&self) -> Result<IndexStats>
Get statistics about the index
Sourcepub async fn migrate_from_jsonl(&self, jsonl_path: &Path) -> Result<usize>
pub async fn migrate_from_jsonl(&self, jsonl_path: &Path) -> Result<usize>
Migrate from old JSONL format
Auto Trait Implementations§
impl Freeze for SqliteIndex
impl !RefUnwindSafe for SqliteIndex
impl Send for SqliteIndex
impl Sync for SqliteIndex
impl Unpin for SqliteIndex
impl UnsafeUnpin for SqliteIndex
impl !UnwindSafe for SqliteIndex
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> 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