pub struct Database<S: Storage> { /* private fields */ }Expand description
Async façade over storage, search index, and document body cache.
Implementations§
Source§impl<S: Storage> Database<S>
impl<S: Storage> Database<S>
Sourcepub async fn resolve_file_path(
&self,
file_path: impl AsRef<str> + Send,
) -> Result<EntryId>
pub async fn resolve_file_path( &self, file_path: impl AsRef<str> + Send, ) -> Result<EntryId>
Note: NotFound is normal when probing file-vs-directory (REST get_or_list); no err(Debug) to avoid ERROR spam.
pub async fn resolve_directory_path( &self, dir_path: impl AsRef<str> + Send, ) -> Result<EntryId>
pub async fn get_document_meta(&self, file_id: EntryId) -> Result<DocumentMeta>
pub async fn cat_document_bundle( &self, file_id: EntryId, ) -> Result<(DocumentMeta, String)>
pub async fn document_ref_by_path( &self, path: impl AsRef<str> + Send, ) -> Result<DocumentMeta>
Sourcepub async fn append_document_by_path(
&self,
path: impl AsRef<str> + Send,
to_append: impl AsRef<str> + Send,
) -> Result<()>
pub async fn append_document_by_path( &self, path: impl AsRef<str> + Send, to_append: impl AsRef<str> + Send, ) -> Result<()>
Append to an existing file, or create it (and parent directories) if absent.
pub async fn say_document_by_path( &self, path: impl AsRef<str> + Send, from_id: impl AsRef<str> + Send, text: impl AsRef<str> + Send, ) -> Result<()>
pub async fn document_head( &self, file_id: EntryId, lines: u32, ) -> Result<String>
pub async fn document_tail( &self, file_id: EntryId, mode: TailMode, ) -> Result<String>
pub async fn document_slice( &self, file_id: EntryId, start_line: u32, end_line: u32, ) -> Result<String>
pub async fn document_wc(&self, file_id: EntryId) -> Result<WcStats>
pub async fn document_stat( &self, file_id: EntryId, ) -> Result<(DocumentMeta, String, usize)>
pub async fn document_grep( &self, file_id: EntryId, pattern: &str, max_matches: usize, invert_match: bool, ) -> Result<Vec<GrepLine>>
pub async fn search_hits( &self, keywords: impl AsRef<str>, directory_prefix: Option<&str>, limit: usize, ) -> Result<Vec<SearchHit>>
pub async fn document_exists_at_path( &self, path: impl AsRef<str> + Send, ) -> Result<bool>
Sourcepub async fn create_document_at_path(
&self,
path: impl AsRef<str> + Send,
content: impl AsRef<str> + Send,
) -> Result<EntryId>
pub async fn create_document_at_path( &self, path: impl AsRef<str> + Send, content: impl AsRef<str> + Send, ) -> Result<EntryId>
Create a file at an absolute path (parent directories must exist).
Sourcepub async fn put_document_by_path(
&self,
path: impl AsRef<str> + Send,
content: impl AsRef<str> + Send,
) -> Result<()>
pub async fn put_document_by_path( &self, path: impl AsRef<str> + Send, content: impl AsRef<str> + Send, ) -> Result<()>
Create parent directories as needed, then create or replace file body.
Sourcepub async fn cp(
&self,
src: impl AsRef<str> + Send,
dst: impl AsRef<str> + Send,
recursive: bool,
) -> Result<()>
pub async fn cp( &self, src: impl AsRef<str> + Send, dst: impl AsRef<str> + Send, recursive: bool, ) -> Result<()>
Unix-like cp within Tabularium virtual paths.
- File source: copies body to
dst(overwrites); ifdstis an existing directory, copies into it. - Directory source: requires
recursive; copies full subtree, including empty directories.
Source§impl Database<SqliteStorage>
impl Database<SqliteStorage>
Sourcepub async fn init(
db_uri: impl AsRef<str>,
index_path: impl AsRef<Path>,
cache_size: u64,
) -> Result<Self>
pub async fn init( db_uri: impl AsRef<str>, index_path: impl AsRef<Path>, cache_size: u64, ) -> Result<Self>
Opens SQLite at db_uri, Tantivy at index_path, and configures the body cache.
cache_size is the max number of cached document bodies; 0 keeps a cache handle but
disables population (always loads from storage).
Source§impl<S: Storage> Database<S>
impl<S: Storage> Database<S>
Sourcepub async fn wait_until_document_changed(
&self,
file_id: EntryId,
timeout: Duration,
) -> Result<DocumentWaitStatus>
pub async fn wait_until_document_changed( &self, file_id: EntryId, timeout: Duration, ) -> Result<DocumentWaitStatus>
Long-poll until a content-changing write touches file_id, or timeout elapses.
Sourcepub async fn subscribe_document_wait(
&self,
file_id: EntryId,
) -> Result<Receiver<u64>>
pub async fn subscribe_document_wait( &self, file_id: EntryId, ) -> Result<Receiver<u64>>
Subscribe to content-change notifications for file_id.
Sourcepub async fn touch(&self, file_id: EntryId) -> Result<()>
pub async fn touch(&self, file_id: EntryId) -> Result<()>
Expose touch for callers that already hold content elsewhere.
pub async fn create_directory( &self, path: impl AsRef<str> + Send, description: Option<&str>, parents: bool, ) -> Result<EntryId>
pub async fn entry_description( &self, path: impl AsRef<str> + Send, ) -> Result<Option<String>>
pub async fn set_entry_description( &self, path: impl AsRef<str> + Send, description: Option<&str>, ) -> Result<()>
pub async fn delete_directory(&self, path: impl AsRef<str> + Send) -> Result<()>
pub async fn delete_directory_recursive( &self, path: impl AsRef<str> + Send, ) -> Result<()>
pub async fn rename_directory( &self, old_path: impl AsRef<str> + Send, new_path: impl AsRef<str> + Send, ) -> Result<()>
pub async fn move_directory( &self, src_path: impl AsRef<str> + Send, dst_parent: impl AsRef<str> + Send, new_name: impl AsRef<str> + Send, ) -> Result<()>
pub async fn create_file_in_directory( &self, directory_path: impl AsRef<str> + Send, name: impl AsRef<str> + Send, content: impl AsRef<str> + Send, ) -> Result<EntryId>
pub async fn delete_document(&self, file_id: EntryId) -> Result<()>
pub async fn update_document( &self, file_id: EntryId, new_content: impl AsRef<str> + Send, ) -> Result<()>
pub async fn append_document( &self, file_id: EntryId, to_append: impl AsRef<str> + Send, ) -> Result<()>
pub async fn move_document_to_directory( &self, file_id: EntryId, new_parent_path: impl AsRef<str> + Send, new_name: impl AsRef<str> + Send, ) -> Result<()>
pub async fn rename_document( &self, file_id: EntryId, new_name: impl AsRef<str> + Send, ) -> Result<()>
Sourcepub async fn get_document(&self, file_id: EntryId) -> Result<String>
pub async fn get_document(&self, file_id: EntryId) -> Result<String>
Read-through cache; touch runs after content is resolved.
Sourcepub async fn touch_document_by_path(
&self,
path: impl AsRef<str> + Send,
modified_at: Option<Timestamp>,
) -> Result<()>
pub async fn touch_document_by_path( &self, path: impl AsRef<str> + Send, modified_at: Option<Timestamp>, ) -> Result<()>
Unix-like touch: modified_at == None — create an empty file (with parent dirs) if missing, else bump modified_at only.
With Some(ts) — set exact modified_at on an existing file or directory; if the path is missing, create an empty file then apply ts.
pub async fn list_directory( &self, dir_path: impl AsRef<str> + Send, ) -> Result<Vec<ListedEntry>>
Sourcepub async fn search(
&self,
keywords: impl AsRef<str>,
directory_prefix: Option<&str>,
) -> Result<Vec<EntryId>>
pub async fn search( &self, keywords: impl AsRef<str>, directory_prefix: Option<&str>, ) -> Result<Vec<EntryId>>
Full-text search. directory_prefix limits to that directory subtree; None or "/" searches all.
pub async fn reindex(&self, directory_path_filter: Option<&str>) -> Result<()>
Auto Trait Implementations§
impl<S> !Freeze for Database<S>
impl<S> !RefUnwindSafe for Database<S>
impl<S> Send for Database<S>
impl<S> Sync for Database<S>
impl<S> Unpin for Database<S>where
S: Unpin,
impl<S> UnsafeUnpin for Database<S>where
S: UnsafeUnpin,
impl<S> !UnwindSafe for Database<S>
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> 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.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for 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