Struct NodeScene

Source
pub struct NodeScene {
    pub is_owner: bool,
    /* private fields */
}
Expand description

A recursive structure that allows for the storage, saving, and loading of a dormant scene of nodes. The root node is what every node in the scene will have its owner set to.

Fields§

§is_owner: bool

Implementations§

Source§

impl NodeScene

Source

pub fn new<N: Node>(root: N) -> Self

Creates a new NodeScene with a root node.

Source

pub fn new_dyn(root: Box<dyn Node>) -> Self

Creates a new NodeScene from a dynamic node.

Source

pub fn load_from_str(document: &str) -> Result<Self, String>

Loads a NodeScene from a string.

Source

pub fn load(path: &Path) -> Result<Self, String>

Loads a NodeScene from a .scn file.

Source

pub fn save_to_str(&self) -> Result<String, String>

Saves a NodeScene to a string.

Source

pub fn save(&self, path: &Path, name: &str) -> Result<(), String>

Saves a NodeScene to a toml like .scn file.

Source

pub fn structural_hash(&self) -> u64

Recursively builds a hash that represents the scene layout. This will NOT check node fields, but will only compare the shape, ownership, and types present throughout a scene tree.

This can be useful to test for scene changes across loading and saving.

§Note

This uses the default hasher. The Hash trait is also implemented to support hashing with other hash functions.

Source

pub fn append(&mut self, child: NodeScene)

Appends a NodeScene as a child.

Source

pub fn append_as_owner(&mut self, child: NodeScene)

Appends an owning NodeScene as a child, ensuring that the root node of the added NodeScene is always an owner.

Source

pub unsafe fn get_node(&self) -> Box<dyn Node>

Returns this NodeScene instance’s associated node.

§Safety

This is marked unsafe as if the resulting Box<T> is dropped, the internal pointer could be invalidated.

Source

pub fn children(&self) -> &[NodeScene]

Gets the children.

Source

pub fn update_internal(&self, counter: u64)

Updates the internal RIDs.

Trait Implementations§

Source§

impl Clone for NodeScene

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NodeScene

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for NodeScene

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Instanceable for NodeScene

Source§

fn iterate<F: FnMut(Option<*mut dyn Node>, *mut dyn Node, bool)>( self, iterator: F, )

Goes through and iterates through all of the nodes that are represented by this collection. The arguments passed through are the pointers to the parent (if there is one), the node itself, and whether the node is an owner.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Element<T> for T

Source§

fn as_inner(&self) -> &T

Converts the element into its inferred type.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.