id_effect 0.3.0

Effect<A, E, R> (sync + async), capability DI, pipe — interpreter-style, no bundled executor
Documentation
//! Capability key trait (generated by [`#[capability]`](crate::define_capability)).

use super::id::CapabilityId;

/// Associates a generated key type with the concrete service value stored in [`super::Env`].
pub trait CapabilityKey: Copy + Send + Sync + 'static {
  /// Concrete service type (cloneable handle stored in the environment).
  type Value: Clone + Send + Sync + 'static;

  /// Stable id for graph planning and diagnostics.
  fn id() -> CapabilityId {
    CapabilityId::of::<Self>()
  }

  /// Human-readable name for diagnostics (defaults to type name).
  fn name() -> &'static str {
    std::any::type_name::<Self>()
  }
}

/// Marker implemented by all capability service traits.
pub trait Capability: Send + Sync + 'static {}
impl<T: Send + Sync + 'static> Capability for T {}