Skip to main content

cool_plugin/
lib.rs

1//! # cool-plugin
2//!
3//! cool-admin Rust 插件系统。
4//!
5//! ## 功能特性
6//!
7//! - 🔌 插件生命周期管理
8//! - 📦 插件注册和发现
9//! - 🔧 插件配置
10//! - 🪝 钩子系统
11//!
12//! ## 快速开始
13//!
14//! ```rust,ignore
15//! use cool_plugin::prelude::*;
16//!
17//! #[derive(Default)]
18//! struct MyPlugin;
19//!
20//! #[async_trait]
21//! impl Plugin for MyPlugin {
22//!     fn info(&self) -> PluginInfo {
23//!         PluginInfo {
24//!             name: "my-plugin".to_string(),
25//!             key: "my-plugin".to_string(),
26//!             version: "1.0.0".to_string(),
27//!             ..Default::default()
28//!         }
29//!     }
30//!
31//!     async fn ready(&mut self) -> PluginResult<()> {
32//!         // 插件就绪
33//!         Ok(())
34//!     }
35//! }
36//! ```
37
38mod cache;
39mod constant;
40mod exception;
41mod hook;
42mod installer;
43mod plugin;
44mod registry;
45mod service;
46mod upload;
47
48pub use cache::*;
49pub use constant::*;
50pub use exception::*;
51pub use hook::*;
52pub use installer::*;
53pub use plugin::*;
54pub use registry::*;
55pub use service::*;
56pub use upload::*;
57
58/// 预导入模块
59pub mod prelude {
60    pub use crate::cache::{
61        create_cache_store, CacheError, CacheOptions, CacheResult, FsCacheStore,
62    };
63    pub use crate::constant::{ErrInfo, Event, GlobalConfig, ResCode, ResMessage};
64    pub use crate::exception::{
65        BaseException, CoolCommException, CoolCoreException, CoolValidateException,
66    };
67    pub use crate::hook::{Hook, HookContext};
68    pub use crate::installer::{
69        CheckResult, InstallerError, InstallerResult, PluginData, PluginInstaller,
70    };
71    pub use crate::plugin::{Plugin, PluginInfo, PluginResult, PluginStatus};
72    pub use crate::registry::{global_plugin_registry, PluginRegistry};
73    pub use crate::service::{global_plugin_service, PluginService};
74    pub use crate::upload::{
75        LocalUploadHook, Mode, ModeType, PathValidator, UploadContext, UploadError, UploadHook,
76        UploadResult,
77    };
78    pub use async_trait::async_trait;
79}