actionable 0.2.0

An enum-based async framework for building permission-driven APIs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
pub use actionable_macros::Dispatcher;
use async_trait::async_trait;

use crate::Permissions;

/// Dispatches `T` to an appropriate handler. This trait is derivable.
#[async_trait]
pub trait Dispatcher<T>: Send + Sync {
    /// The type of the result.
    type Result: Send + Sync;

    /// Dispatches `request` to the appropriate handler while also ensuring
    /// `permissions` allows the request.
    async fn dispatch(&self, permissions: &Permissions, request: T) -> Self::Result;
}