rhombus

Trait Plugin

source
pub trait Plugin {
    // Provided methods
    async fn upload_provider(
        &self,
        context: &UploadProviderContext<'_>,
    ) -> Option<impl UploadProvider + Send + Sync> { ... }
    async fn database_provider(
        &self,
        _context: &mut DatabaseProviderContext<'_>,
    ) -> Option<(Arc<dyn Database + Send + Sync>, Box<dyn Any + Send + Sync>)> { ... }
    async fn run<U: UploadProvider>(
        &self,
        context: &mut RunContext<'_, U>,
    ) -> Result<Router<Arc<RouterStateInner>>> { ... }
}
Expand description

A plugin can be used to extend Rhombus with custom functionality, themes, or localization.

§Order of execution

First, review and understand the Builder Order of Execution.

  1. The upload_provider function is called for each plugin in reverse order of plugins defined until the first plugin is found which implements a custom upload provider, which is then used. If no plugin implements a custom upload provider, the default upload provider creation process will happen.
  2. The run function is called for each plugin in the order they are defined.

Provided Methods§

source

async fn upload_provider( &self, context: &UploadProviderContext<'_>, ) -> Option<impl UploadProvider + Send + Sync>

Supply a custom UploadProvider.

struct MyUploadProviderPlugin;

/// Simple local upload provider wrapper
impl Plugin for MyUploadProviderPlugin {
    async fn upload_provider(
        &self,
        context: &UploadProviderContext<'_>,
    ) -> Option<impl UploadProvider + Send + Sync> {
         let local = LocalUploadProvider::new("myplugin-uploads".into());
         Some(local)
    }
}
source

async fn database_provider( &self, _context: &mut DatabaseProviderContext<'_>, ) -> Option<(Arc<dyn Database + Send + Sync>, Box<dyn Any + Send + Sync>)>

source

async fn run<U: UploadProvider>( &self, context: &mut RunContext<'_, U>, ) -> Result<Router<Arc<RouterStateInner>>>

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Plugin for ()

Empty plugin implementation for internal heterogeneous plugin tuples.

source§

impl<P, P2> Plugin for (P, P2)
where P: Plugin, P2: Plugin,

Plugin implementation for internal two plugin tuple heterogenous plugin tuple.

source§

async fn upload_provider( &self, context: &UploadProviderContext<'_>, ) -> Option<impl UploadProvider + Send + Sync>

source§

async fn database_provider( &self, context: &mut DatabaseProviderContext<'_>, ) -> Option<(Arc<dyn Database + Send + Sync>, Box<dyn Any + Send + Sync>)>

source§

async fn run<U: UploadProvider>( &self, context: &mut RunContext<'_, U>, ) -> Result<Router<Arc<RouterStateInner>>>

source§

impl<P: Plugin> Plugin for (P,)

Plugin implementation for internal single plugin heterogenous plugin tuple.

source§

async fn upload_provider( &self, context: &UploadProviderContext<'_>, ) -> Option<impl UploadProvider + Send + Sync>

source§

async fn database_provider( &self, context: &mut DatabaseProviderContext<'_>, ) -> Option<(Arc<dyn Database + Send + Sync>, Box<dyn Any + Send + Sync>)>

source§

async fn run<U: UploadProvider>( &self, context: &mut RunContext<'_, U>, ) -> Result<Router<Arc<RouterStateInner>>>

Implementors§