spring_boot/plugin/
mod.rs1pub mod component;
2
3use crate::app::AppBuilder;
4use async_trait::async_trait;
5use std::{any::Any, ops::Deref, sync::Arc};
6
7#[derive(Clone)]
8pub struct PluginRef(Arc<dyn Plugin>);
9
10#[async_trait]
11pub trait Plugin: Any + Send + Sync {
12 async fn build(&self, app: &mut AppBuilder);
14
15 fn name(&self) -> &str {
18 std::any::type_name::<Self>()
19 }
20
21 fn dependencies(&self) -> Vec<&str> {
23 vec![]
24 }
25}
26
27impl PluginRef {
28 pub(crate) fn new<T: Plugin>(plugin: T) -> Self {
29 Self(Arc::new(plugin))
30 }
31}
32
33impl Deref for PluginRef {
34 type Target = dyn Plugin;
35
36 fn deref(&self) -> &Self::Target {
37 &*self.0
38 }
39}