actionable 0.1.0-dev.2

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
use async_trait::async_trait;

pub use actionable_macros::Dispatcher;

use crate::Permissions;

/// Dispatches `T` to an appropriate handler. This trait is derivable.
#[async_trait]
pub trait Dispatcher<T> {
    /// 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;
}