rust_query::migration

Struct Prepare

Source
pub struct Prepare { /* private fields */ }
Expand description

Prepare is used to open a database from a file or in memory.

Implementations§

Source§

impl Prepare

Source

pub fn open(p: impl AsRef<Path>) -> Self

Open a database that is stored in a file. Creates the database if it does not exist.

Opening the same database multiple times at the same time is fine, as long as they migrate to or use the same schema. All locking is done by sqlite, so connections can even be made using different client implementations.

We currently don’t check that the schema is not modified between transactions. So if that happens then the subsequent queries might fail.

Source

pub fn open_in_memory() -> Self

Creates a new empty database in memory.

Source

pub fn create_db_sql<S: Schema>(self, sql: &[&str]) -> Option<Migrator<S>>

Execute a raw sql statement if the database was just created. The sql code is executed after creating the empty database. Returns None if the database schema is older than S. This function will panic if the resulting schema is different, but the version matches.

Source

pub fn create_db_empty<S: Schema>(self) -> Option<Migrator<S>>

Create empty tables based on the schema if the database was just created. Returns None if the database schema is older than S. This function will panic if the resulting schema is different, but the version matches.

Auto Trait Implementations§

§

impl !Freeze for Prepare

§

impl !RefUnwindSafe for Prepare

§

impl Send for Prepare

§

impl !Sync for Prepare

§

impl Unpin for Prepare

§

impl !UnwindSafe for Prepare

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