Skip to main content

Resource

Trait Resource 

Source
pub trait Resource:
    Send
    + Sync
    + 'static { }
Expand description

A type that can be stored in State as a “resource.”

Resources are useful for plugin state that is not directly related to a specific entity. For example, you might store your plugin’s configuration in a Resource.

Use State::resource and State::resource_mut to access resources. Similarly, use Setup::resource to create a resource when your plugin is loaded.

This trait is automatically implemented for most types.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> Resource for T
where T: Send + Sync + 'static,