macro_rules! resources {
(
$(#[$container_meta:meta])*
$container_vis:vis struct $container:ident {
$(
$(#[$field_meta:meta])*
$field_vis:vis $field:ident : $field_type:ty $(=> $tag:ty)?
),* $(,)?
}
) => { ... };
(@provider $container:ident, $field:ident, $field_type:ty) => { ... };
(@provider $container:ident, $field:ident, $field_type:ty, $tag:ty) => { ... };
}Expand description
Declares an application resource container and its typed field providers.
Each field type is available through Res<T> and
ResMut<T>. A tag after => distinguishes fields that have the
same type.
§Examples
use dispatch_core::resources;
struct Primary;
struct Backup;
resources! {
struct Resources {
counter: u32,
primary_port: u16 => Primary,
backup_port: u16 => Backup,
}
}A type may occur only once without a tag. Implement ResourceProvider
manually when the container already exists or lookup requires a custom
backend.
ⓘ
use dispatch_core::resources;
resources! {
struct Ambiguous {
first: u32,
second: u32,
}
}