Skip to main content

USAGE

Constant USAGE 

Source
pub const USAGE: &str = "见本模块文档";
Expand description

bee-rust 集成的用法要点(示例不参与编译,bee-rust 的路由构造需要真实状态)。

use encryption::guard::Guard;
use encryption::integrations::Guarded;
use bee_router::Router;

#[derive(Clone)]
struct AppState { encryption: Guard }
impl Guarded for AppState {
    fn guard(&self) -> &Guard { &self.encryption }
}

async fn health(guard: Guard) -> String {
    format!("algorithms={}", guard.identifiers().len())
}

let app = Router::new()
    .ns("/api/v1", |ns| ns.get("/health", health))
    .with_state(AppState { encryption: guard });