Trait legion::systems::ResourceSet[][src]

pub trait ResourceSet<'a> {
    type Result: 'a;
    unsafe fn fetch_unchecked(resources: &'a UnsafeResources) -> Self::Result;

    fn fetch_mut(resources: &'a mut Resources) -> Self::Result { ... }
fn fetch(resources: &'a Resources) -> Self::Result
    where
        Self: ReadOnly
, { ... } }
Expand description

Trait which is implemented for tuples of resources and singular resources. This abstracts fetching resources to allow for ergonomic fetching.

Example:

struct TypeA(usize);
struct TypeB(usize);

let mut resources = Resources::default();
resources.insert(TypeA(55));
resources.insert(TypeB(12));

{
    let (a, mut b) = <(Read<TypeA>, Write<TypeB>)>::fetch_mut(&mut resources);
    assert_ne!(a.0, b.0);
    b.0 = a.0;
}

{
    let (a, b) = <(Read<TypeA>, Read<TypeB>)>::fetch(&resources);
    assert_eq!(a.0, b.0);
}

Associated Types

The resource reference returned during a fetch.

Required methods

Fetches all defined resources, without checking mutability.

Safety

It is up to the end user to validate proper mutability rules across the resources being accessed.

Provided methods

Fetches all defined resources.

Fetches all defined resources.

Implementations on Foreign Types

Implementors