pub struct TestApplierGuard<'a> { /* private fields */ }Expand description
Mutable access to the applier of a TestComposition, with the app context of that composition
active while the guard lives.
Methods from Deref<Target = MemoryApplier>§
Sourcepub fn slots_handle(&self) -> Rc<RefCell<SlotTable>>
pub fn slots_handle(&self) -> Rc<RefCell<SlotTable>>
The slot table that composition during layout writes to, shared with the layout pass that lends this applier.
Sourcepub fn scene_node_attached_to(
&mut self,
node_id: usize,
root: usize,
) -> Option<usize>
pub fn scene_node_attached_to( &mut self, node_id: usize, root: usize, ) -> Option<usize>
Resolves a scene-scope candidate the way structural records are
resolved: to its nearest non-virtual ancestor, and only while still
attached to root. A node detached after recording must not reach the
scoped scene update — an id the graph cannot resolve forces it to give
up and rebuild the whole scene.
Sourcepub fn scene_nodes_attached_to(
&mut self,
nodes: impl IntoIterator<Item = usize>,
root: usize,
) -> Vec<Option<usize>>
pub fn scene_nodes_attached_to( &mut self, nodes: impl IntoIterator<Item = usize>, root: usize, ) -> Vec<Option<usize>>
Self::scene_node_attached_to for each of nodes, in order, with
every ancestor looked up at most once: a batch costs the distinct
ancestors of its nodes, not each node’s depth.
Sourcepub fn scene_nodes_attached_to_into(
&mut self,
nodes: impl IntoIterator<Item = usize>,
root: usize,
output: &mut Vec<Option<usize>>,
scratch: &mut SceneNodeAttachmentScratch,
)
pub fn scene_nodes_attached_to_into( &mut self, nodes: impl IntoIterator<Item = usize>, root: usize, output: &mut Vec<Option<usize>>, scratch: &mut SceneNodeAttachmentScratch, )
Fills output with Self::scene_nodes_attached_to results, reusing
its storage and the ancestry cache in scratch across batches.
Each distinct ancestor is inspected at most once per call. The cache is cleared for each call, so graph mutations are observed by the next batch.
use cranpose_core::{MemoryApplier, NodeId, SceneNodeAttachmentScratch};
let mut applier = MemoryApplier::new();
let mut scratch = SceneNodeAttachmentScratch::default();
let mut attached: Vec<Option<NodeId>> = Vec::new();
let root = NodeId::default();
applier.scene_nodes_attached_to_into([], root, &mut attached, &mut scratch);
assert!(attached.is_empty());Sourcepub fn take_structural_change_parents_attached_to(
&mut self,
root: usize,
) -> Vec<usize>
pub fn take_structural_change_parents_attached_to( &mut self, root: usize, ) -> Vec<usize>
Drains the parents recorded via Applier::record_structural_change,
keeping only nodes still attached to root (a parent that was itself
removed is covered by its own surviving ancestor’s record). A virtual
parent — a subcompose slot wrapper the render graph never contains —
is reported as its nearest non-virtual ancestor: that is the node
whose graph child set the change altered, and an id the graph cannot
resolve would force the scoped scene update to give up and rebuild.
Sourcepub fn take_structural_change_parents_into(&mut self, output: &mut Vec<usize>)
pub fn take_structural_change_parents_into(&mut self, output: &mut Vec<usize>)
Takes the recorded structural-change candidates into reusable storage.
Candidates are not resolved or attachment-filtered; callers that route
them into scenes should use Self::scene_nodes_attached_to_into.
use cranpose_core::MemoryApplier;
let mut applier = MemoryApplier::new();
let mut nodes = Vec::new();
applier.take_structural_change_parents_into(&mut nodes);
assert!(nodes.is_empty());Sourcepub fn with_node<N, R>(
&mut self,
id: usize,
f: impl FnOnce(&mut N) -> R,
) -> Result<R, NodeError>where
N: Node + 'static,
pub fn with_node<N, R>(
&mut self,
id: usize,
f: impl FnOnce(&mut N) -> R,
) -> Result<R, NodeError>where
N: Node + 'static,
Runs f on the node id as an N. Returns an error if the node does not exist or is not
an N.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the number of slots in the dense node table, both live and free.
Sourcepub fn tombstone_count(&self) -> usize
pub fn tombstone_count(&self) -> usize
Returns the number of free slots in the dense node table.
Sourcepub fn freelist_len(&self) -> usize
pub fn freelist_len(&self) -> usize
Returns the number of freed table slots that new nodes can reuse.
Sourcepub fn debug_recycled_node_count(&self) -> usize
pub fn debug_recycled_node_count(&self) -> usize
Returns the number of pooled recycled nodes of all types.
Sourcepub fn debug_recycled_node_count_for<N>(&self) -> usizewhere
N: Node + 'static,
pub fn debug_recycled_node_count_for<N>(&self) -> usizewhere
N: Node + 'static,
Returns the number of pooled recycled nodes of type N.
Sourcepub fn debug_stats(&self) -> MemoryApplierDebugStats
pub fn debug_stats(&self) -> MemoryApplierDebugStats
Returns the sizes of the applier’s tables, for leak and memory checks.
Sourcepub fn for_each_node_mut(
&mut self,
visit: impl FnMut(&mut (dyn Node + 'static)),
)
pub fn for_each_node_mut( &mut self, visit: impl FnMut(&mut (dyn Node + 'static)), )
Calls visit with every live node, dense and high-id alike.
Sourcepub fn debug_live_node_heap_bytes(&self) -> usize
pub fn debug_live_node_heap_bytes(&self) -> usize
Returns the heap bytes that the live nodes take, including what they own.
Sourcepub fn debug_recycled_node_heap_bytes(&self) -> usize
pub fn debug_recycled_node_heap_bytes(&self) -> usize
Returns the heap bytes that the pooled recycled nodes take, including what they own.
Sourcepub fn set_runtime_handle(&mut self, handle: RuntimeHandle)
pub fn set_runtime_handle(&mut self, handle: RuntimeHandle)
Gives the applier the runtime of its composition, so code that runs during layout with only the applier in hand can reach the runtime.
Sourcepub fn clear_runtime_handle(&mut self)
pub fn clear_runtime_handle(&mut self)
Removes the runtime handle.
Sourcepub fn runtime_handle(&self) -> Option<RuntimeHandle>
pub fn runtime_handle(&self) -> Option<RuntimeHandle>
Returns the runtime handle set with set_runtime_handle, if any.
Trait Implementations§
Source§impl Deref for TestApplierGuard<'_>
impl Deref for TestApplierGuard<'_>
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for TestApplierGuard<'a>
impl<'a> !Send for TestApplierGuard<'a>
impl<'a> !Sync for TestApplierGuard<'a>
impl<'a> !UnwindSafe for TestApplierGuard<'a>
impl<'a> Freeze for TestApplierGuard<'a>
impl<'a> Unpin for TestApplierGuard<'a>
impl<'a> UnsafeUnpin for TestApplierGuard<'a>
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
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more