use async_trait::async_trait;
use alun_core::{Plugin, Result};
use alun_utils::Sid;
pub struct SidPlugin;
impl SidPlugin {
pub fn new() -> Self { Self }
pub fn uuid(&self) -> String { Sid::uuid() }
pub fn short(&self) -> String { Sid::short() }
pub fn tiny(&self) -> String { Sid::tiny() }
pub fn uuid7(&self) -> String { Sid::uuid7() }
pub fn tsid(&self) -> String { Sid::tsid() }
pub fn biz_id(&self, prefix: &str) -> String {
format!("{}_{}", prefix, Sid::uuid7())
}
}
impl Default for SidPlugin {
fn default() -> Self { Self }
}
#[async_trait]
impl Plugin for SidPlugin {
fn name(&self) -> &str { "sid" }
async fn start(&self) -> Result<()> {
tracing::info!("短ID插件就绪");
Ok(())
}
async fn stop(&self) -> Result<()> { Ok(()) }
}