dioxus/packages/core/src/bump_frame.rs

29 lines
620 B
Rust
Raw Normal View History

use std::cell::Cell;
use bumpalo::Bump;
2022-11-04 03:56:31 +00:00
use crate::factory::RenderReturn;
pub struct BumpFrame {
pub bump: Bump,
2022-11-04 03:56:31 +00:00
pub node: Cell<*mut RenderReturn<'static>>,
}
impl BumpFrame {
pub fn new(capacity: usize) -> Self {
let bump = Bump::with_capacity(capacity);
Self {
bump,
2022-11-04 03:56:31 +00:00
node: Cell::new(std::ptr::null_mut()),
}
}
pub fn reset(&mut self) {
self.bump.reset();
2022-11-04 03:56:31 +00:00
self.node.set(std::ptr::null_mut());
}
2022-11-12 02:29:27 +00:00
pub unsafe fn load_node<'b>(&self) -> &'b RenderReturn<'b> {
unsafe { std::mem::transmute(&*self.node.get()) }
}
}