WritableDatabase

Struct WritableDatabase 

Source
pub struct WritableDatabase(/* private fields */);
Expand description

A Xapian database that can be read or written to

Implementations§

Source§

impl WritableDatabase

Source

pub fn open( path: impl AsRef<Path>, action: impl Into<Option<DbAction>>, backend: impl Into<Option<DbBackend>>, flags: impl Into<Option<DbFlags>>, block_size: impl Into<Option<i32>>, ) -> Self

Open a database for updates

Automatically selects the appropriate backend to use

Source

pub fn inmemory() -> Self

Create a new, in-memory WritableDatabase

Source

pub fn add_database(&mut self, db: impl AsRef<WritableDatabase>)

Add shards from another WritableDatabase

Source

pub fn add_document(&mut self, doc: impl AsRef<Document>) -> DocId

Add a new document to the database

Source

pub fn add_spelling( &self, word: impl AsRef<str>, increment: impl Into<Option<u32>>, )

Add a word to the spelling dictionary

Source

pub fn add_synonym(&self, term: impl AsRef<str>, synonym: impl AsRef<str>)

Add a synonym for a term

Source

pub fn begin_transaction(&mut self, flushed: impl Into<Option<bool>>)

Begin a transaction

Source

pub fn cancel_transaction(&mut self)

Abort the transaction currently in progress

Source

pub fn commit_transaction(&mut self)

Complete the transaction currently in progress

Source

pub fn close(&mut self)

Close the database

Source

pub fn commit(&mut self)

Commit any pending modifications made to the database

Source

pub fn delete_document(&mut self, id: impl Into<DocId>)

Delete the document (if any) matching the specified DocId from the database

Source

pub fn delete_document_by_term(&mut self, term: impl AsRef<str>)

Delete any documents indexed by the specified term from the database

Source

pub fn doc_count(&self) -> u32

Get the number of documents in the database

Source

pub fn metadata(&self, key: impl AsRef<str>) -> Bytes

Get the user-specified metadata associated with a given key

Source

pub fn read_only(&self) -> Database

Retrieve a read-only Database instance backed by this WritableDatabase

Source

pub fn remove_spelling( &self, word: impl AsRef<str>, decrement: impl Into<Option<u32>>, )

Remove a word from the spelling dictionary

Source

pub fn remove_synonym(&self, term: impl AsRef<str>, synonym: impl AsRef<str>)

Remove the given synonym for the specified term

Source

pub fn replace_document( &mut self, id: impl Into<DocId>, doc: impl AsRef<Document>, )

Replace the document (if any) matching the specified DocId from the database with the specified doc

Source

pub fn replace_document_by_term( &mut self, term: impl AsRef<str>, doc: impl AsRef<Document>, ) -> u32

Replace any documents matching the given term

Source

pub fn transaction( &mut self, flushed: impl Into<Option<bool>>, f: impl FnMut(&mut WritableDatabase), )

Wrap the function specified in f in a transaction

Trait Implementations§

Source§

impl Default for WritableDatabase

Source§

fn default() -> Self

Open a new, in-memory WritableDatabase

Source§

impl From<&WritableDatabase> for Database

Source§

fn from(value: &WritableDatabase) -> Self

Converts to this type from the input type.
Source§

impl From<WritableDatabase> for Database

Source§

fn from(value: WritableDatabase) -> Self

Converts to this type from the input type.

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