Struct Database

Source
pub struct Database<S> { /* private fields */ }
Expand description

Database is a proof that the database has been configured.

For information on how to create transactions, please refer to LocalClient.

Creating a Database requires going through the steps to migrate an existing database to the required schema, or creating a new database from scratch. Having done the setup to create a compatible database is sadly not a guarantee that the database will stay compatible for the lifetime of the Database.

That is why Database also stores the schema_version. This allows detecting non-malicious modifications to the schema and gives us the ability to panic when this is detected. Such non-malicious modification of the schema can happen for example if another Database instance is created with additional migrations (e.g. by another newer instance of your program).

§Sqlite config

Sqlite is configured to be in WAL mode. The effect of this mode is that there can be any number of readers with one concurrent writer. What is nice about this is that a Transaction can always be made immediately. Making a TransactionMut has to wait until all other TransactionMuts are finished.

Sqlite is also configured with synchronous=NORMAL. This gives better performance by fsyncing less. The database will not lose transactions due to application crashes, but it might due to system crashes or power loss.

Auto Trait Implementations§

§

impl<S> !Freeze for Database<S>

§

impl<S> !RefUnwindSafe for Database<S>

§

impl<S> Send for Database<S>
where S: Send,

§

impl<S> Sync for Database<S>
where S: Sync,

§

impl<S> Unpin for Database<S>
where S: Unpin,

§

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