Skip to main content

Resource

Trait Resource 

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

Marker trait for types that can be stored in a World.

Requires Send + 'static. Use #[derive(Resource)] to implement, or new_resource! for newtype wrappers.

use nexus_rt::Resource;

#[derive(Resource)]
struct OrderBook {
    bids: Vec<(f64, f64)>,
    asks: Vec<(f64, f64)>,
}

§Why not just Send + 'static?

Without the marker trait, two modules can independently register u64 and silently collide. The Resource bound forces a newtype, making collisions a compile error.

Implementations on Foreign Types§

Source§

impl<T: Send + 'static, S: SlabStore<Item = WheelEntry<T>> + 'static> Resource for TimerWheel<T, S>

Implementors§