FnMigration

Struct FnMigration 

Source
pub struct FnMigration<Ctx, F, R>
where F: Fn(&mut Ctx) -> Result<(), Error> + Send + Sync, R: Fn(&mut Ctx) -> Result<(), Error> + Send + Sync,
{ /* private fields */ }
Expand description

Builder for creating simple migrations with closures

Implementations§

Source§

impl<Ctx, F> FnMigration<Ctx, F, fn(&mut Ctx) -> Result<(), Error>>
where F: Fn(&mut Ctx) -> Result<(), Error> + Send + Sync,

Source

pub fn new( version: u64, name: impl Into<String>, apply_fn: F, ) -> FnMigration<Ctx, F, fn(&mut Ctx) -> Result<(), Error>>

Source§

impl<Ctx, F, R> FnMigration<Ctx, F, R>
where F: Fn(&mut Ctx) -> Result<(), Error> + Send + Sync, R: Fn(&mut Ctx) -> Result<(), Error> + Send + Sync,

Source

pub fn phase(self, phase: Phase) -> FnMigration<Ctx, F, R>

Set the deployment phase

Source

pub fn with_rollback<R2>(self, rollback_fn: R2) -> FnMigration<Ctx, F, R2>
where R2: Fn(&mut Ctx) -> Result<(), Error> + Send + Sync,

Trait Implementations§

Source§

impl<Ctx, F, R> Migration<Ctx> for FnMigration<Ctx, F, R>
where F: Fn(&mut Ctx) -> Result<(), Error> + Send + Sync, R: Fn(&mut Ctx) -> Result<(), Error> + Send + Sync,

Source§

fn version(&self) -> u64

Unique version number (must be sequential: 1, 2, 3, …)
Source§

fn name(&self) -> &str

Human-readable name for this migration
Source§

fn phase(&self) -> Phase

Deployment phase (pre-deploy or post-deploy)
Source§

fn apply(&self, ctx: &mut Ctx) -> Result<(), Error>

Apply the migration
Source§

fn rollback(&self, ctx: &mut Ctx) -> Result<(), Error>

Rollback the migration (optional)
Source§

fn can_rollback(&self) -> bool

Whether this migration supports rollback

Auto Trait Implementations§

§

impl<Ctx, F, R> Freeze for FnMigration<Ctx, F, R>
where F: Freeze, R: Freeze,

§

impl<Ctx, F, R> RefUnwindSafe for FnMigration<Ctx, F, R>

§

impl<Ctx, F, R> Send for FnMigration<Ctx, F, R>

§

impl<Ctx, F, R> Sync for FnMigration<Ctx, F, R>

§

impl<Ctx, F, R> Unpin for FnMigration<Ctx, F, R>
where F: Unpin, R: Unpin,

§

impl<Ctx, F, R> UnwindSafe for FnMigration<Ctx, F, R>
where F: UnwindSafe, R: UnwindSafe,

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.