BootstrapPhase

Trait BootstrapPhase 

Source
pub trait BootstrapPhase: Sealed {
    type RequestHandler: Debug;
    type ErrorHandler: Debug;
    type Config: Debug;
    type Apps;
    type Router: Debug;
    type Database: Debug;
    type AuthBackend;
}
Expand description

A trait that represents the different phases of the bootstrapper.

This trait is used to define the types for the different phases of the bootstrapper. It’s used to ensure that you can’t access nonexistent data until the bootstrapper has reached the corresponding phase.

§Order of phases

  1. Uninitialized
  2. WithConfig
  3. WithApps
  4. WithDatabase
  5. Initialized

§Sealed

This trait is sealed and can’t be implemented outside the cot crate.

§Examples

use cot::project::{MiddlewareContext, RegisterAppsContext, RootHandler, RootHandlerBuilder};
use cot::{AppBuilder, Project};

struct MyProject;
impl Project for MyProject {
    // `WithConfig` phase here
    fn register_apps(&self, apps: &mut AppBuilder, context: &RegisterAppsContext) {
        unimplemented!();
    }

    // `WithDatabase` phase here (which comes after `WithConfig`)
    fn middlewares(
        &self,
        handler: RootHandlerBuilder,
        context: &MiddlewareContext,
    ) -> RootHandler {
        unimplemented!()
    }
}

Required Associated Types§

Source

type RequestHandler: Debug

The type of the request handler.

Source

type ErrorHandler: Debug

The type of the error handler.

Source

type Config: Debug

The type of the configuration.

Source

type Apps

The type of the apps.

Source

type Router: Debug

The type of the router.

Source

type Database: Debug

Available on crate feature db only.

The type of the database.

Source

type AuthBackend

The type of the auth backend.

Implementors§

Source§

impl BootstrapPhase for Initialized

Source§

impl BootstrapPhase for Uninitialized

Source§

impl BootstrapPhase for WithApps

Source§

impl BootstrapPhase for WithConfig

Source§

impl BootstrapPhase for WithDatabase