tork-core 0.1.0

Core runtime for the Tork web framework: HTTP server, routing, dependency injection, responses, and errors, built on Hyper and Tokio.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! The resource registry contract.
//!
//! A resource container declares which of its fields are resources. At startup
//! each resource is inserted into the application registry by type, so services
//! and handlers can inject it directly rather than reaching through a state
//! object.

use crate::state::StateMap;

/// A type that contributes resources to the application registry.
///
/// Implemented by `#[derive(Resources)]`, which registers each `#[resource]`
/// field (by a clone) under its type.
pub trait Resources: Send + Sync + 'static {
    /// Inserts each declared resource into `registry`.
    fn register(&self, registry: &mut StateMap);
}