Struct Migration

Source
pub struct Migration<T> {
    pub from: fn() -> Version,
    pub to: fn() -> Version,
    pub up: fn(&Migration<T>, &mut T) -> Result<(), Box<dyn Error>>,
    pub down: fn(&Migration<T>, &mut T) -> Result<(), Box<dyn Error>>,
}

Fields§

§from: fn() -> Version§to: fn() -> Version§up: fn(&Migration<T>, &mut T) -> Result<(), Box<dyn Error>>§down: fn(&Migration<T>, &mut T) -> Result<(), Box<dyn Error>>

Implementations§

Source§

impl<T> Migration<T>

Source

pub fn from(&self) -> Version

Source

pub fn to(&self) -> Version

Source

pub fn change( &self, doc: &mut T, from: &Version, to: &Version, ) -> Result<ChangeResult, Box<dyn Error>>

Source

pub fn migrate_from( from: &Version, to: &Version, doc: &mut T, migrations: &[Self], ) -> Result<bool, Box<dyn Error>>

Source

pub fn migrate( version: &Version, doc: &mut T, migrations: &[Self], ) -> Result<bool, Box<dyn Error>>

Migrate the database schema to the current version. If the version is already the current version, nothing is done. If the version is older, the database is upgraded. If the version is newer, the database is downgraded. Returns true if the database was migrated, false if it was already at the current version.

Auto Trait Implementations§

§

impl<T> Freeze for Migration<T>

§

impl<T> RefUnwindSafe for Migration<T>

§

impl<T> Send for Migration<T>

§

impl<T> Sync for Migration<T>

§

impl<T> Unpin for Migration<T>

§

impl<T> UnwindSafe for Migration<T>

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.