Skip to main content

Database

Struct Database 

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

Source

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.

Source

pub async fn resolve_directory_path( &self, dir_path: impl AsRef<str> + Send, ) -> Result<EntryId>

Source

pub async fn get_document_meta(&self, file_id: EntryId) -> Result<DocumentMeta>

Source

pub async fn cat_document_bundle( &self, file_id: EntryId, ) -> Result<(DocumentMeta, String)>

Source

pub async fn document_ref_by_path( &self, path: impl AsRef<str> + Send, ) -> Result<DocumentMeta>

Source

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.

Source

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<()>

Source

pub async fn document_head( &self, file_id: EntryId, lines: u32, ) -> Result<String>

Source

pub async fn document_tail( &self, file_id: EntryId, mode: TailMode, ) -> Result<String>

Source

pub async fn document_slice( &self, file_id: EntryId, start_line: u32, end_line: u32, ) -> Result<String>

Source

pub async fn document_wc(&self, file_id: EntryId) -> Result<WcStats>

Source

pub async fn document_stat( &self, file_id: EntryId, ) -> Result<(DocumentMeta, String, usize)>

Source

pub async fn document_grep( &self, file_id: EntryId, pattern: &str, max_matches: usize, invert_match: bool, ) -> Result<Vec<GrepLine>>

Source

pub async fn search_hits( &self, keywords: impl AsRef<str>, directory_prefix: Option<&str>, limit: usize, ) -> Result<Vec<SearchHit>>

Source

pub async fn document_exists_at_path( &self, path: impl AsRef<str> + Send, ) -> Result<bool>

Source

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).

Source

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.

Source

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); if dst is an existing directory, copies into it.
  • Directory source: requires recursive; copies full subtree, including empty directories.
Source

pub async fn resolve_existing_file_path( &self, path: impl AsRef<str> + Send, ) -> Result<EntryId>

Resolve path for RPC: file path must exist as a file.

Source§

impl Database<SqliteStorage>

Source

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>

Source

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.

Source

pub async fn subscribe_document_wait( &self, file_id: EntryId, ) -> Result<Receiver<u64>>

Subscribe to content-change notifications for file_id.

Source

pub async fn touch(&self, file_id: EntryId) -> Result<()>

Expose touch for callers that already hold content elsewhere.

Source

pub async fn create_directory( &self, path: impl AsRef<str> + Send, description: Option<&str>, parents: bool, ) -> Result<EntryId>

Source

pub async fn entry_description( &self, path: impl AsRef<str> + Send, ) -> Result<Option<String>>

Source

pub async fn set_entry_description( &self, path: impl AsRef<str> + Send, description: Option<&str>, ) -> Result<()>

Source

pub async fn delete_directory(&self, path: impl AsRef<str> + Send) -> Result<()>

Source

pub async fn delete_directory_recursive( &self, path: impl AsRef<str> + Send, ) -> Result<()>

Source

pub async fn rename_directory( &self, old_path: impl AsRef<str> + Send, new_path: impl AsRef<str> + Send, ) -> Result<()>

Source

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<()>

Source

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>

Source

pub async fn delete_document(&self, file_id: EntryId) -> Result<()>

Source

pub async fn update_document( &self, file_id: EntryId, new_content: impl AsRef<str> + Send, ) -> Result<()>

Source

pub async fn append_document( &self, file_id: EntryId, to_append: impl AsRef<str> + Send, ) -> Result<()>

Source

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<()>

Source

pub async fn rename_document( &self, file_id: EntryId, new_name: impl AsRef<str> + Send, ) -> Result<()>

Source

pub async fn get_document(&self, file_id: EntryId) -> Result<String>

Read-through cache; touch runs after content is resolved.

Source

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.

Source

pub async fn list_directory( &self, dir_path: impl AsRef<str> + Send, ) -> Result<Vec<ListedEntry>>

Source

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.

Source

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> 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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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

impl<T> Fruit for T
where T: Send + Downcast,