Skip to main content

SqliteIndex

Struct SqliteIndex 

Source
pub struct SqliteIndex { /* private fields */ }
Expand description

SQLite-based file index

Implementations§

Source§

impl SqliteIndex

Source

pub async fn new(db_path: PathBuf) -> Result<Self>

Create a new SQLite index at the given path

Source

pub async fn load(db_path: PathBuf) -> Result<Self>

Load index from existing database (alias for new)

Source

pub async fn get( &self, id: &str, include_deleted: bool, ) -> Result<Option<FileIndexEntry>>

Get an entry by ID

§Arguments
  • id - The file ID
  • include_deleted - If true, include soft-deleted files
Source

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.

Source

pub async fn restore(&self, id: &str) -> Result<bool>

Restore a soft-deleted file

Clears the deleted_at timestamp, making the file accessible again.

Source

pub async fn list_deleted(&self) -> Result<Vec<FileIndexEntry>>

List all soft-deleted files

Source

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
Source

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.

Source

pub async fn insert(&self, entry: FileIndexEntry) -> Result<()>

Insert or update an entry

Source

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.

Source

pub async fn update_ref_count( &self, id: &str, delta: i32, ) -> Result<Option<usize>>

Update reference count for an entry

§Arguments
  • id - The file ID
  • delta - Change in reference count (+1 to add, -1 to release)
§Returns

The new reference count, or None if the entry doesn’t exist

Source

pub async fn get_candidates_for_cleanup( &self, threshold: i32, max_age_days: u32, ) -> Result<Vec<FileIndexEntry>>

Get entries suitable for cleanup

Source

pub async fn len(&self) -> Result<usize>

Get total entry count

Source

pub async fn is_empty(&self) -> Result<bool>

Check if index is empty

Source

pub async fn entries(&self) -> Result<Vec<FileIndexEntry>>

Get all entries (use sparingly with large datasets)

Source

pub async fn stats(&self) -> Result<IndexStats>

Get statistics about the index

Source

pub async fn close(&self)

Close the database connection

Source

pub async fn migrate_from_jsonl(&self, jsonl_path: &Path) -> Result<usize>

Migrate from old JSONL format

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more