macro_rules! backend_capabilities {
($($(#[$attr:meta])* $method:ident : $trait:ident),* $(,)?) => { ... };
}Expand description
Implement the as_*_mut upcasting helpers on a backend struct.
Each Backend implementor must return Some(self) for every trait it
supports and None for those it does not. Without this macro that is four
lines of boilerplate per capability. The macro expands to those lines
automatically and allows attaching per-capability doc comments.
§Usage
ⓘ
use rite_sdk::{Backend, KeyStoreBackend, SignBackend};
impl Backend for MyBackend {
fn name(&self) -> &str { &self.name }
fn provider(&self) -> &str { "software" }
fn fingerprint(&self) -> String { "...".to_string() }
backend_capabilities!(
/// Supports RSA-2048 through RSA-8192 key generation and storage.
as_keystore_mut: KeyStoreBackend,
as_sign_mut: SignBackend,
);
}Capabilities not listed here are not overridden, so they inherit the trait’s
default doc (“Not supported by this backend.”) and return None.
The trait names passed to the macro must be in scope at the call site.
Note: #[macro_export] places this macro at the crate root
(rite_sdk::backend_capabilities!), not in the backend module.
This is standard Rust macro scoping.