VoxelTree

Struct VoxelTree 

Source
pub struct VoxelTree<T: Display> { /* private fields */ }
Expand description

This struct is used to own a [NodeData] inside an Arc. The Arc can be shared, so that it can have multiple owners. It does not have getter methods for [NodeData]’s properties, instead it implements the Deref trait to allow it to be used as a [NodeData].

§Shared ownership

After an instance of this struct is created and it’s internal reference is cloned (and given to another) dropping this instance will not drop the cloned internal reference.

VoxelTree { arc_ref: Arc<NodeData> }
   ▲                 ▲
   │                 │
   │      This atomic ref owns the
   │      `NodeData` & is shared
   │
   1. Has methods to manipulate nodes and their children.

   2. When it is dropped, if there are other `Arc`s (shared via
      `get_copy_of_internal_arc()`) pointing to the same underlying
      `NodeData`, then the `NodeData` will not be dropped.

   3. This struct is necessary in order for `add_child_and_update_its_parent`
      to work. Some pointers need to be swapped between 2 nodes for this work
      (and one of these pointers is a weak one). It is not possible to do this
      using two `NodeData` objects, without wrapping them in `Arc`s.

Implementations§

Source§

impl<T> VoxelTree<T>
where T: Display,

Source

pub fn new(value: T) -> VoxelTree<T>

Source

pub fn get_copy_of_internal_arc(&self) -> NodeDataRef<T>

Source

pub fn create_and_add_child(&self, value: T) -> NodeDataRef<T>

Source

pub fn add_child_and_update_its_parent(&self, child: &VoxelTree<T>)

🔏 Write locks used.

Source

pub fn has_parent(&self) -> bool

Source

pub fn get_parent(&self) -> Option<NodeDataRef<T>>

🔒 Read lock used.

Trait Implementations§

Source§

impl<T> Deref for VoxelTree<T>
where T: Display,

Source§

type Target = NodeData<T>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<T> Freeze for VoxelTree<T>

§

impl<T> RefUnwindSafe for VoxelTree<T>
where T: RefUnwindSafe,

§

impl<T> Send for VoxelTree<T>
where T: Sync + Send,

§

impl<T> Sync for VoxelTree<T>
where T: Sync + Send,

§

impl<T> Unpin for VoxelTree<T>

§

impl<T> UnwindSafe for VoxelTree<T>
where T: RefUnwindSafe,

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> 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.