#[resource]
Expand description
Registers the annotated Resource
to a #[butler_plugin]
and
initializes it upon the plugin being added.
§Usage
§On a struct
#[derive(Resource, Default)]
#[resource(plugin = MyPlugin)]
struct Counter(pub u8);
§On an imported type
#[resource(plugin = MyPlugin)]
use my_mod::ModResource;
§On a type alias
#[resource(plugin = MyPlugin)]
type MyResource = ExternalResource<usize>;
§Arguments
§plugin
(Required)
A Plugin
annotated with #[butler_plugin]
to register this resource to.
§init
By default, #[resource]
will use the Default
value of the resource.
This can be overridden by specifying an init
value.
#[derive(Resource)]
#[resource(
plugin = MyPlugin,
init = Message("Hello, world!".to_string())
)]
struct Message(String);
§generics
A list of generic arguments to register the resource with. Used to register a generic resource for multiple different types.
§non_send
If your resource should not be sent between threads, including non_send
will register it using
init_non_send_resource
/
insert_non_send_resource
.
Can be written as non_send
, non_send = <bool>
or non_send(<bool>)
.
#[derive(Resource, Default)]
#[resource(plugin = MyPlugin, non_send)]
struct MyNonSendResource;