Extension

Trait Extension 

Source
pub trait Extension: Send + Sync {
    // Provided methods
    fn initialize<'life0, 'async_trait>(
        &'life0 mut self,
        state: State,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn initialize_cli<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        env: Option<&'life1 Arc<Env>>,
        builder: CliCommandGroupBuilder,
    ) -> Pin<Box<dyn Future<Output = CliCommandGroupBuilder> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn initialize_router<'life0, 'async_trait>(
        &'life0 mut self,
        state: State,
        builder: ExtensionRouteBuilder,
    ) -> Pin<Box<dyn Future<Output = ExtensionRouteBuilder> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn initialize_background_tasks<'life0, 'async_trait>(
        &'life0 mut self,
        state: State,
        builder: BackgroundTaskBuilder,
    ) -> Pin<Box<dyn Future<Output = BackgroundTaskBuilder> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn initialize_shutdown_handlers<'life0, 'async_trait>(
        &'life0 mut self,
        state: State,
        builder: ShutdownHandlerBuilder,
    ) -> Pin<Box<dyn Future<Output = ShutdownHandlerBuilder> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn initialize_permissions<'life0, 'async_trait>(
        &'life0 mut self,
        state: State,
        builder: ExtensionPermissionsBuilder,
    ) -> Pin<Box<dyn Future<Output = ExtensionPermissionsBuilder> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn settings_deserializer<'life0, 'async_trait>(
        &'life0 self,
        state: State,
    ) -> Pin<Box<dyn Future<Output = ExtensionSettingsDeserializer> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn process_call<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
        args: &'life2 [ExtensionCallValue],
    ) -> Pin<Box<dyn Future<Output = Option<ExtensionCallValue>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn process_call_owned<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
        args: Vec<ExtensionCallValue>,
    ) -> Pin<Box<dyn Future<Output = Option<ExtensionCallValue>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}

Provided Methods§

Source

fn initialize<'life0, 'async_trait>( &'life0 mut self, state: State, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Your extension entrypoint, this runs as soon as the database is migrated and before the webserver starts

Source

fn initialize_cli<'life0, 'life1, 'async_trait>( &'life0 mut self, env: Option<&'life1 Arc<Env>>, builder: CliCommandGroupBuilder, ) -> Pin<Box<dyn Future<Output = CliCommandGroupBuilder> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Your extension cli entrypoint, this runs after the env has been parsed

Source

fn initialize_router<'life0, 'async_trait>( &'life0 mut self, state: State, builder: ExtensionRouteBuilder, ) -> Pin<Box<dyn Future<Output = ExtensionRouteBuilder> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Your extension routes entrypoint, this runs as soon as the database is migrated and before the webserver starts

Source

fn initialize_background_tasks<'life0, 'async_trait>( &'life0 mut self, state: State, builder: BackgroundTaskBuilder, ) -> Pin<Box<dyn Future<Output = BackgroundTaskBuilder> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Your extension background tasks entrypoint, this runs as soon as the database is migrated and before the webserver starts

Source

fn initialize_shutdown_handlers<'life0, 'async_trait>( &'life0 mut self, state: State, builder: ShutdownHandlerBuilder, ) -> Pin<Box<dyn Future<Output = ShutdownHandlerBuilder> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Your extension shutdown handler entrypoint, this runs as soon as the database is migrated and before the webserver starts

Source

fn initialize_permissions<'life0, 'async_trait>( &'life0 mut self, state: State, builder: ExtensionPermissionsBuilder, ) -> Pin<Box<dyn Future<Output = ExtensionPermissionsBuilder> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Your extension permissions entrypoint, this runs as soon as the database is migrated and before the webserver starts

Source

fn settings_deserializer<'life0, 'async_trait>( &'life0 self, state: State, ) -> Pin<Box<dyn Future<Output = ExtensionSettingsDeserializer> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Your extension settings deserializer, this is used to deserialize your extension settings from the database Whatever value you return in the deserialize_boxed method must match the trait ExtensionSettings, which requires SettingsSerializeExt to be implemented for it. If you have no clue what this means. copy code from the docs.

Source

fn process_call<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, name: &'life1 str, args: &'life2 [ExtensionCallValue], ) -> Pin<Box<dyn Future<Output = Option<ExtensionCallValue>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Your extension call processor, this can be called by other extensions to interact with yours, if the call does not apply to your extension, simply return None to continue the matching process.

Optimally (if applies) make sure your calls are globally unique, for example by prepending them with your package name

Source

fn process_call_owned<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, args: Vec<ExtensionCallValue>, ) -> Pin<Box<dyn Future<Output = Option<ExtensionCallValue>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Your extension call processor, this can be called by other extensions to interact with yours, if the call does not apply to your extension, simply return None to continue the matching process.

The only difference to process_call is that this takes an owned vec, its automatically implemented in terms of process_call.

Optimally (if applies) make sure your calls are globally unique, for example by prepending them with your package name

Implementors§