Struct seshat::Database

source ·
pub struct Database { /* private fields */ }
Expand description

The Seshat database.

Implementations§

source§

impl Database

source

pub fn new<P: AsRef<Path>>(path: P) -> Result<Database>where PathBuf: From<P>,

Create a new Seshat database or open an existing one.

Arguments
  • path - The directory where the database will be stored in. This should be an empty directory if a new database should be created.
source

pub fn new_with_config<P: AsRef<Path>>( path: P, config: &Config ) -> Result<Database>where PathBuf: From<P>,

Create a new Seshat database or open an existing one with the given configuration.

Arguments
  • path - The directory where the database will be stored in. This should be an empty directory if a new database should be created.
  • config - Configuration that changes the behaviour of the database.
source

pub fn change_passphrase(self, new_passphrase: &str) -> Result<()>

Change the passphrase of the Seshat database.

Note that this consumes the database object and any searcher objects can’t be used anymore. A new database will have to be opened and new searcher objects as well.

Arguments
  • path - The directory where the database will be stored in. This should be an empty directory if a new database should be created.
  • new_passphrase - The passphrase that should be used instead of the current one.
source

pub fn get_size(&self) -> Result<u64>

Get the size of the database. This returns the number of bytes the database is using on disk.

source

pub fn get_path(&self) -> &Path

Get the path of the directory where the Seshat database lives in.

source

pub fn add_event(&self, event: Event, profile: Profile)

Add an event with the given profile to the database.

Arguments
  • event - The directory where the database will be stored in. This
  • profile - The directory where the database will be stored in. This

This is a fast non-blocking operation, it only queues up the event to be added to the database. The events will be committed to the database only when the user calls the commit() method.

source

pub fn delete_event(&self, event_id: &str) -> Receiver<Result<bool>>

Delete an event from the database.

Arguments
  • event_id - The event id of the event that will be deleted.

Note for the event to be completely removed a commit needs to be done.

Returns a receiver that will receive an boolean once the event has been deleted. The boolean indicates if the event was deleted or if a commit will be needed.

source

pub fn commit(&mut self) -> Result<()>

Commit the currently queued up events. This method will block. A non-blocking version of this method exists in the commit_no_wait() method.

source

pub fn force_commit(&mut self) -> Result<()>

Commit the currently queued up events forcing the commit to the index.

Commits are usually rate limited. This gets around the limit and forces the documents to be added to the index.

This method will block. A non-blocking version of this method exists in the force_commit_no_wait() method.

This should only be used for testing purposes.

source

pub fn reload(&mut self) -> Result<()>

Reload the database so that a search reflects the state of the last commit. Note that this happens automatically and this method should be used only in unit tests.

source

pub fn commit_no_wait(&mut self) -> Receiver<Result<()>>

Commit the currently queued up events without waiting for confirmation that the operation is done.

Returns a receiver that will receive an empty message once the commit is done.

source

pub fn force_commit_no_wait(&mut self) -> Receiver<Result<()>>

Commit the currently queued up events forcing the commit to the index.

Commits are usually rate limited. This gets around the limit and forces the documents to be added to the index.

This should only be used for testing purposes.

Returns a receiver that will receive an empty message once the commit is done.

source

pub fn add_historic_events( &self, events: Vec<(Event, Profile)>, new_checkpoint: Option<CrawlerCheckpoint>, old_checkpoint: Option<CrawlerCheckpoint> ) -> Receiver<Result<bool>>

Add the given events from the room history to the database.

Arguments
  • events - The events that will be added.
  • new_checkpoint - A checkpoint that states where we need to continue fetching events from the room history. This checkpoint will be persisted in the database.
  • old_checkpoint - The checkpoint that was used to fetch the given events. This checkpoint will be removed from the database.
source

pub fn search(&self, term: &str, config: &SearchConfig) -> Result<SearchBatch>

Search the index and return events matching a search term. This is just a helper function that gets a searcher and performs a search on it immediately.

Arguments
  • term - The search term that should be used to search the index.
source

pub fn get_searcher(&self) -> Searcher

Get a searcher that can be used to perform a search.

source

pub fn get_connection(&self) -> Result<Connection>

Get a database connection. Note that this connection should only be used for reading.

source

pub fn shutdown(self) -> Receiver<Result<()>>

Shut the database down.

This will terminate the writer thread making sure that no writes will happen after this operation.

source

pub fn delete(self) -> Result<()>

Delete the database. Warning: This will delete the whole path that was provided at the database creation time.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for Twhere T: Any,

§

fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>

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

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

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

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

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

§

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 Twhere U: TryFrom<T>,

§

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

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> Erased for T

source§

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