pub struct MkAllocatorRes { /* private fields */ }Expand description
Bevy resource wrapping the memkit allocator.
Use this to access frame allocations in your systems:
fn my_system(alloc: Res<MkAllocatorRes>) {
let data = alloc.frame_alloc::<MyStruct>();
// data is valid until end of frame
}Implementations§
Source§impl MkAllocatorRes
impl MkAllocatorRes
Sourcepub fn allocator(&self) -> &MkAllocator
pub fn allocator(&self) -> &MkAllocator
Get a reference to the underlying allocator.
Sourcepub fn is_frame_active(&self) -> bool
pub fn is_frame_active(&self) -> bool
Check if a frame is currently active.
Sourcepub fn frame_alloc<T>(&self) -> *mut T
pub fn frame_alloc<T>(&self) -> *mut T
Allocate a value in the current frame’s arena.
Returns a raw pointer to uninitialized memory. You must initialize it.
§Panics
Panics if called outside of an active frame.
Sourcepub fn frame_slice<T>(&self, len: usize) -> Option<MkFrameSlice<'_, T>>
pub fn frame_slice<T>(&self, len: usize) -> Option<MkFrameSlice<'_, T>>
Allocate a slice in the current frame’s arena.
Returns an MkFrameSlice wrapper if successful.
Sourcepub fn frame_box<T>(&self, value: T) -> Option<MkFrameBox<'_, T>>
pub fn frame_box<T>(&self, value: T) -> Option<MkFrameBox<'_, T>>
Allocate and initialize a value in the frame arena.
Returns an MkFrameBox wrapper if successful.
Methods from Deref<Target = MkAllocator>§
Sourcepub fn begin_frame(&self)
pub fn begin_frame(&self)
Begin a new frame. Must be paired with end_frame().
Sourcepub fn frame_alloc<T>(&self) -> *mut T
pub fn frame_alloc<T>(&self) -> *mut T
Allocate from the frame arena.
Sourcepub fn frame_box<T>(&self, value: T) -> Option<MkFrameBox<'_, T>>
pub fn frame_box<T>(&self, value: T) -> Option<MkFrameBox<'_, T>>
Allocate a value in the frame arena and return a box.
Sourcepub fn frame_slice<T>(&self, len: usize) -> Option<MkFrameSlice<'_, T>>
pub fn frame_slice<T>(&self, len: usize) -> Option<MkFrameSlice<'_, T>>
Allocate a slice in the frame arena.
Sourcepub fn frame_vec<T>(&self, capacity: usize) -> Option<MkFrameVec<'_, T>>
pub fn frame_vec<T>(&self, capacity: usize) -> Option<MkFrameVec<'_, T>>
Allocate a vector in the frame arena with the given capacity.
Sourcepub fn frame_head(&self) -> usize
pub fn frame_head(&self) -> usize
Get the current frame head position (for checkpointing).
Sourcepub fn reset_frame_to(&self, pos: usize)
pub fn reset_frame_to(&self, pos: usize)
Reset frame to a checkpoint position.
Trait Implementations§
Source§impl Deref for MkAllocatorRes
impl Deref for MkAllocatorRes
impl Resource for MkAllocatorRes
Auto Trait Implementations§
impl Freeze for MkAllocatorRes
impl RefUnwindSafe for MkAllocatorRes
impl Send for MkAllocatorRes
impl Sync for MkAllocatorRes
impl Unpin for MkAllocatorRes
impl UnwindSafe for MkAllocatorRes
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.