Trait SceneGraph

Source
pub trait SceneGraph: BaseSceneGraph {
Show 25 methods // Required methods fn pair_iter( &self, ) -> impl Iterator<Item = (Handle<Self::Node>, &Self::Node)>; fn linear_iter(&self) -> impl Iterator<Item = &Self::Node>; fn linear_iter_mut(&mut self) -> impl Iterator<Item = &mut Self::Node>; // Provided methods fn try_get_of_type<T>(&self, handle: Handle<Self::Node>) -> Option<&T> where T: 'static { ... } fn try_get_mut_of_type<T>( &mut self, handle: Handle<Self::Node>, ) -> Option<&mut T> where T: 'static { ... } fn has_component<T>(&self, handle: Handle<Self::Node>) -> bool where T: 'static { ... } fn find_map<C, T>( &self, root_node: Handle<Self::Node>, cmp: &mut C, ) -> Option<(Handle<Self::Node>, &T)> where C: FnMut(&Self::Node) -> Option<&T>, T: ?Sized { ... } fn find_up<C>( &self, root_node: Handle<Self::Node>, cmp: &mut C, ) -> Option<(Handle<Self::Node>, &Self::Node)> where C: FnMut(&Self::Node) -> bool { ... } fn find_handle_up<C>( &self, root_node: Handle<Self::Node>, cmp: &mut C, ) -> Handle<Self::Node> where C: FnMut(&Self::Node) -> bool { ... } fn find_component_up<T>( &self, node_handle: Handle<Self::Node>, ) -> Option<(Handle<Self::Node>, &T)> where T: 'static { ... } fn find_component<T>( &self, node_handle: Handle<Self::Node>, ) -> Option<(Handle<Self::Node>, &T)> where T: 'static { ... } fn find_up_map<C, T>( &self, root_node: Handle<Self::Node>, cmp: &mut C, ) -> Option<(Handle<Self::Node>, &T)> where C: FnMut(&Self::Node) -> Option<&T>, T: ?Sized { ... } fn find_by_name( &self, root_node: Handle<Self::Node>, name: &str, ) -> Option<(Handle<Self::Node>, &Self::Node)> { ... } fn find_up_by_name( &self, root_node: Handle<Self::Node>, name: &str, ) -> Option<(Handle<Self::Node>, &Self::Node)> { ... } fn find_by_name_from_root( &self, name: &str, ) -> Option<(Handle<Self::Node>, &Self::Node)> { ... } fn find_handle_by_name_from_root(&self, name: &str) -> Handle<Self::Node> { ... } fn find_from_root<C>( &self, cmp: &mut C, ) -> Option<(Handle<Self::Node>, &Self::Node)> where C: FnMut(&Self::Node) -> bool { ... } fn find<C>( &self, root_node: Handle<Self::Node>, cmp: &mut C, ) -> Option<(Handle<Self::Node>, &Self::Node)> where C: FnMut(&Self::Node) -> bool { ... } fn find_handle<C>( &self, root_node: Handle<Self::Node>, cmp: &mut C, ) -> Handle<Self::Node> where C: FnMut(&Self::Node) -> bool { ... } fn relative_position( &self, child: Handle<Self::Node>, offset: isize, ) -> Option<(Handle<Self::Node>, usize)> { ... } fn traverse_iter( &self, from: Handle<Self::Node>, ) -> impl Iterator<Item = (Handle<Self::Node>, &Self::Node)> { ... } fn traverse_handle_iter( &self, from: Handle<Self::Node>, ) -> impl Iterator<Item = Handle<Self::Node>> { ... } fn restore_integrity<F>( &mut self, instantiate: F, ) -> Vec<(Handle<Self::Node>, Resource<Self::Prefab>)> where F: FnMut(Resource<Self::Prefab>, &Self::Prefab, Handle<Self::Node>, &mut Self) -> (Handle<Self::Node>, NodeHandleMap<Self::Node>) { ... } fn restore_original_handles_and_inherit_properties<F>( &mut self, ignored_types: &[TypeId], before_inherit: F, ) where F: FnMut(&Self::Node, &mut Self::Node) { ... } fn remap_handles( &mut self, instances: &[(Handle<Self::Node>, Resource<Self::Prefab>)], ) { ... }
}

Required Methods§

Source

fn pair_iter(&self) -> impl Iterator<Item = (Handle<Self::Node>, &Self::Node)>

Creates new iterator that iterates over internal collection giving (handle; node) pairs.

Source

fn linear_iter(&self) -> impl Iterator<Item = &Self::Node>

Creates an iterator that has linear iteration order over internal collection of nodes. It does not perform any tree traversal!

Source

fn linear_iter_mut(&mut self) -> impl Iterator<Item = &mut Self::Node>

Creates an iterator that has linear iteration order over internal collection of nodes. It does not perform any tree traversal!

Provided Methods§

Source

fn try_get_of_type<T>(&self, handle: Handle<Self::Node>) -> Option<&T>
where T: 'static,

Tries to borrow a node and fetch its component of specified type.

Source

fn try_get_mut_of_type<T>( &mut self, handle: Handle<Self::Node>, ) -> Option<&mut T>
where T: 'static,

Tries to mutably borrow a node and fetch its component of specified type.

Source

fn has_component<T>(&self, handle: Handle<Self::Node>) -> bool
where T: 'static,

Tries to borrow a node by the given handle and checks if it has a component of the specified type.

Source

fn find_map<C, T>( &self, root_node: Handle<Self::Node>, cmp: &mut C, ) -> Option<(Handle<Self::Node>, &T)>
where C: FnMut(&Self::Node) -> Option<&T>, T: ?Sized,

Searches for a node down the tree starting from the specified node using the specified closure. Returns a tuple with a handle and a reference to the mapped value. If nothing is found, it returns None.

Source

fn find_up<C>( &self, root_node: Handle<Self::Node>, cmp: &mut C, ) -> Option<(Handle<Self::Node>, &Self::Node)>
where C: FnMut(&Self::Node) -> bool,

Searches for a node up the tree starting from the specified node using the specified closure. Returns a tuple with a handle and a reference to the found node. If nothing is found, it returns None.

Source

fn find_handle_up<C>( &self, root_node: Handle<Self::Node>, cmp: &mut C, ) -> Handle<Self::Node>
where C: FnMut(&Self::Node) -> bool,

The same as Self::find_up, but only returns node handle which will be Handle::NONE if nothing is found.

Source

fn find_component_up<T>( &self, node_handle: Handle<Self::Node>, ) -> Option<(Handle<Self::Node>, &T)>
where T: 'static,

Source

fn find_component<T>( &self, node_handle: Handle<Self::Node>, ) -> Option<(Handle<Self::Node>, &T)>
where T: 'static,

Source

fn find_up_map<C, T>( &self, root_node: Handle<Self::Node>, cmp: &mut C, ) -> Option<(Handle<Self::Node>, &T)>
where C: FnMut(&Self::Node) -> Option<&T>, T: ?Sized,

Searches for a node up the tree starting from the specified node using the specified closure. Returns a tuple with a handle and a reference to the mapped value. If nothing is found, it returns None.

Source

fn find_by_name( &self, root_node: Handle<Self::Node>, name: &str, ) -> Option<(Handle<Self::Node>, &Self::Node)>

Searches for a node with the specified name down the tree starting from the specified node. Returns a tuple with a handle and a reference to the found node. If nothing is found, it returns None.

Source

fn find_up_by_name( &self, root_node: Handle<Self::Node>, name: &str, ) -> Option<(Handle<Self::Node>, &Self::Node)>

Searches for a node with the specified name up the tree starting from the specified node. Returns a tuple with a handle and a reference to the found node. If nothing is found, it returns None.

Source

fn find_by_name_from_root( &self, name: &str, ) -> Option<(Handle<Self::Node>, &Self::Node)>

Searches for a node with the specified name down the tree starting from the graph root. Returns a tuple with a handle and a reference to the found node. If nothing is found, it returns None.

Source

fn find_handle_by_name_from_root(&self, name: &str) -> Handle<Self::Node>

Source

fn find_from_root<C>( &self, cmp: &mut C, ) -> Option<(Handle<Self::Node>, &Self::Node)>
where C: FnMut(&Self::Node) -> bool,

Searches node using specified compare closure starting from root. Returns a tuple with a handle and a reference to the found node. If nothing is found, it returns None.

Source

fn find<C>( &self, root_node: Handle<Self::Node>, cmp: &mut C, ) -> Option<(Handle<Self::Node>, &Self::Node)>
where C: FnMut(&Self::Node) -> bool,

Searches for a node down the tree starting from the specified node using the specified closure. Returns a tuple with a handle and a reference to the found node. If nothing is found, it returns None.

Source

fn find_handle<C>( &self, root_node: Handle<Self::Node>, cmp: &mut C, ) -> Handle<Self::Node>
where C: FnMut(&Self::Node) -> bool,

The same as Self::find, but only returns node handle which will be Handle::NONE if nothing is found.

Source

fn relative_position( &self, child: Handle<Self::Node>, offset: isize, ) -> Option<(Handle<Self::Node>, usize)>

Returns position of the node in its parent children list and the handle to the parent. Adds given offset to the position. For example, if you have the following hierarchy:

A_
 |B
 |C

Calling this method with a handle of C will return Some((handle_of(A), 1)). The returned value will be clamped in the 0..parent_child_count range. None will be returned only if the given handle is invalid, or it is the root node.

Source

fn traverse_iter( &self, from: Handle<Self::Node>, ) -> impl Iterator<Item = (Handle<Self::Node>, &Self::Node)>

Create a graph depth traversal iterator.

Source

fn traverse_handle_iter( &self, from: Handle<Self::Node>, ) -> impl Iterator<Item = Handle<Self::Node>>

Create a graph depth traversal iterator.

Source

fn restore_integrity<F>( &mut self, instantiate: F, ) -> Vec<(Handle<Self::Node>, Resource<Self::Prefab>)>
where F: FnMut(Resource<Self::Prefab>, &Self::Prefab, Handle<Self::Node>, &mut Self) -> (Handle<Self::Node>, NodeHandleMap<Self::Node>),

This method checks integrity of the graph and restores it if needed. For example, if a node was added in a parent asset, then it must be added in the graph. Alternatively, if a node was deleted in a parent asset, then its instance must be deleted in the graph.

Source

fn restore_original_handles_and_inherit_properties<F>( &mut self, ignored_types: &[TypeId], before_inherit: F, )
where F: FnMut(&Self::Node, &mut Self::Node),

Source

fn remap_handles( &mut self, instances: &[(Handle<Self::Node>, Resource<Self::Prefab>)], )

Maps handles in properties of instances after property inheritance. It is needed, because when a property contains node handle, the handle cannot be used directly after inheritance. Instead, it must be mapped to respective instance first.

To do so, we at first, build node handle mapping (original handle -> instance handle) starting from instance root. Then we must find all inheritable properties and try to remap them to instance handles.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§