Skip to main content

CapabilityKey

Trait CapabilityKey 

Source
pub trait CapabilityKey: 'static {
    type Capability: ?Sized + Send + Sync + 'static;

    const NAME: &'static str;
}
Expand description

The key trait for identifying capabilities in Kit.

Each capability is identified by a unique key type that implements this trait. The Capability associated type specifies the trait object type of the capability. The NAME constant provides a diagnostic name for error messages.

§Type Constraints

The Capability type must satisfy:

  • ?Sized — allows trait objects like dyn SomeTrait
  • Send + Sync + 'static — required for thread-safe storage in Kit

The key type itself must satisfy 'static for TypeId stability.

§Example

use trait_kit::core::capability::CapabilityKey;

struct MyKey;
impl CapabilityKey for MyKey {
    type Capability = dyn Send + Sync;
    const NAME: &'static str = "my_key";
}

let _ = MyKey::NAME;

Required Associated Constants§

Source

const NAME: &'static str

The diagnostic name for this capability key. Used in error messages like MissingCapability { key: "main_logger" }.

Required Associated Types§

Source

type Capability: ?Sized + Send + Sync + 'static

The capability trait object type. Must satisfy ?Sized + Send + Sync + 'static.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§