Struct bones_lib::ecs::resources::UntypedResource
pub struct UntypedResource { /* private fields */ }
Expand description
An untyped resource that may be inserted into UntypedResources
.
This is fundamentally a Arc<AtomicCell<Option<SchemaBox>>>
and thus represents
a cell that may or may not contain a resource of it’s schema.
Implementations§
§impl UntypedResource
impl UntypedResource
pub fn empty(schema: &'static Schema) -> UntypedResource
pub fn empty(schema: &'static Schema) -> UntypedResource
Initialize a new, empty UntypedResource
.
pub fn new(resource: SchemaBox) -> UntypedResource
pub fn new(resource: SchemaBox) -> UntypedResource
Creates a new UntypedResource
storing the given data.
pub fn from_default(schema: &'static Schema) -> UntypedResource
pub fn from_default(schema: &'static Schema) -> UntypedResource
Create a new UntypedResource
for the given schema, initially populated with the default
value for the schema.
pub fn clone_data(&self) -> Option<SchemaBox>
pub fn clone_data(&self) -> Option<SchemaBox>
Clone the inner data, creating a new copy instead of returning another handle the the same
data, as the normal clone()
implementation does.
pub fn insert(
&self,
data: SchemaBox,
) -> Result<Option<SchemaBox>, SchemaMismatchError>
pub fn insert( &self, data: SchemaBox, ) -> Result<Option<SchemaBox>, SchemaMismatchError>
Insert resource data into the cell, returning the previous data.
§Errors
Errors if the schema of the data does not match that of this cell.
pub fn borrow_mut(&self) -> RefMut<'_, Option<SchemaBox>>
pub fn borrow_mut(&self) -> RefMut<'_, Option<SchemaBox>>
Mutably borrow the resource.
pub fn schema(&self) -> &'static Schema
pub fn schema(&self) -> &'static Schema
Get the schema of the resource.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for UntypedResource
impl !RefUnwindSafe for UntypedResource
impl Send for UntypedResource
impl Sync for UntypedResource
impl Unpin for UntypedResource
impl !UnwindSafe for UntypedResource
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