Struct bones_ecs::resources::AtomicResource
source · pub struct AtomicResource<T: HasSchema> { /* private fields */ }
Expand description
A handle to a resource from a Resources
collection.
This is not the resource itself, but a cheaply clonable handle to it.
To access the resource you must borrow it with either borrow()
or
borrow_mut()
.
Implementations§
source§impl<T: HasSchema> AtomicResource<T>
impl<T: HasSchema> AtomicResource<T>
sourcepub fn from_untyped(
untyped: AtomicUntypedResource,
) -> Result<Self, SchemaMismatchError>
pub fn from_untyped( untyped: AtomicUntypedResource, ) -> Result<Self, SchemaMismatchError>
Create from an UntypedResource
.
sourcepub fn borrow(&self) -> Option<Ref<'_, T>>
pub fn borrow(&self) -> Option<Ref<'_, T>>
Lock the resource for reading.
This returns a read guard, very similar to an RwLock
.
sourcepub fn borrow_mut(&self) -> Option<RefMut<'_, T>>
pub fn borrow_mut(&self) -> Option<RefMut<'_, T>>
Lock the resource for read-writing.
This returns a write guard, very similar to an RwLock
.
sourcepub fn into_untyped(self) -> AtomicUntypedResource
pub fn into_untyped(self) -> AtomicUntypedResource
Convert into an untyped resource.
source§impl<T: HasSchema + FromWorld> AtomicResource<T>
impl<T: HasSchema + FromWorld> AtomicResource<T>
sourcepub fn init(&self, world: &World)
pub fn init(&self, world: &World)
Initialize the resource using it’s FromWorld
implementation, if it is not present.
sourcepub fn init_borrow(&self, world: &World) -> Ref<'_, T>
pub fn init_borrow(&self, world: &World) -> Ref<'_, T>
Borrow the resource, initializing it if it doesn’t exist.
sourcepub fn init_borrow_mut(&self, world: &World) -> RefMut<'_, T>
pub fn init_borrow_mut(&self, world: &World) -> RefMut<'_, T>
Borrow the resource, initializing it if it doesn’t exist.
Trait Implementations§
source§impl<T: Clone + HasSchema> Clone for AtomicResource<T>
impl<T: Clone + HasSchema> Clone for AtomicResource<T>
source§fn clone(&self) -> AtomicResource<T>
fn clone(&self) -> AtomicResource<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<T> Freeze for AtomicResource<T>
impl<T> !RefUnwindSafe for AtomicResource<T>
impl<T> Send for AtomicResource<T>
impl<T> Sync for AtomicResource<T>
impl<T> Unpin for AtomicResource<T>where
T: Unpin,
impl<T> !UnwindSafe for AtomicResource<T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
source§fn from_world(_world: &World) -> T
fn from_world(_world: &World) -> T
Creates
Self
using data from the given World
.