Skip to main content

Kernel

Struct Kernel 

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

A booted application: its router, database, queue and maintenance commands.

Implementations§

Source§

impl Kernel

Source

pub async fn call( &self, name: &str, args: impl IntoIterator<Item = impl Into<String>>, ) -> Result

Runs the app command name (see App::command), e.g. from a test.

Source

pub async fn run_scheduled(&self, name: &str) -> Result

Runs the scheduled task name now, with its hooks (what schedule:run does). In a test, TestApp::run_scheduled does the same at the time TestApp::travel moved the clock to.

Source

pub fn router(&self) -> Router

The assembled router, e.g. to drive with tower::ServiceExt::oneshot.

Source

pub fn routes(&self) -> &[RouteInfo]

Every route, sorted by path, as route:list prints them.

Source

pub fn state(&self) -> &AppState

What handlers get as State<AppState>.

Source

pub fn db(&self) -> &Db

The database connection pool.

Source

pub fn mailer(&self) -> &Mailer

The mailer; with MAIL_MAILER=memory, mailer().sent() lists what was sent.

Source

pub fn worker(&self, queues: Vec<String>) -> Worker

A worker for the given queues (all queues when empty).

Source

pub async fn run_jobs(&self) -> Result<usize>

Runs every job that is available now, e.g. in tests; returns how many ran.

Source

pub async fn serve(self) -> Result

Serves HTTP with queue workers and the scheduler in the same process, until Ctrl-C or SIGTERM; then lets running jobs finish.

Source

pub async fn migrate(&self) -> Result<Vec<String>>

Runs pending migrations; returns their names.

Source

pub async fn rollback(&self, batches: u32) -> Result<Vec<String>>

Undoes the last batches batches of migrations; returns their names.

Source

pub async fn fresh(&self) -> Result<Vec<String>>

Drops every table and runs all migrations.

Source

pub async fn migration_status(&self) -> Result<Vec<MigrationStatus>>

Every migration and whether it has run, as migrate:status prints them.

Source

pub async fn seed(&self) -> Result

Runs every seeder in registration order.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Fake for T

Source§

fn fake<U>(&self) -> U
where Self: FakeBase<U>,

Source§

fn fake_with_rng<U, R>(&self, rng: &mut R) -> U
where R: RngExt + ?Sized, Self: FakeBase<U>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more