| Crates.io | unistore-core |
| lib.rs | unistore-core |
| version | 0.1.0 |
| created_at | 2026-01-15 15:43:05.50453+00 |
| updated_at | 2026-01-20 01:16:43.380887+00 |
| description | Core traits and types for UniStore capabilities |
| homepage | https://github.com/yangbo1317/unistore |
| repository | https://github.com/yangbo1317/unistore |
| max_upload_size | |
| id | 2045880 |
| size | 43,726 |
UniStore 能力层核心定义 crate,提供所有能力模块共享的 trait 和类型。
unistore-core 是 UniStore 能力体系的基石,定义了:
Capability trait - 所有能力的核心契约CapabilityInfo - 能力元数据CapabilityError - 统一错误类型CapabilityRegistry - 能力注册与管理[dependencies]
unistore-core = "0.1"
use unistore_core::{Capability, CapabilityInfo, CapabilityError};
use async_trait::async_trait;
pub struct MyCapability {
started: bool,
}
#[async_trait]
impl Capability for MyCapability {
fn info(&self) -> CapabilityInfo {
CapabilityInfo::new("my-capability", "0.1.0")
.with_description("My custom capability")
}
async fn start(&mut self) -> Result<(), CapabilityError> {
self.started = true;
Ok(())
}
async fn stop(&mut self) -> Result<(), CapabilityError> {
self.started = false;
Ok(())
}
async fn health_check(&self) -> Result<(), CapabilityError> {
if self.started {
Ok(())
} else {
Err(CapabilityError::unhealthy("my-capability", "not started"))
}
}
}
MIT OR Apache-2.0