Struct Node

Source
pub struct Node<C> { /* private fields */ }
Expand description

Represents a value within the graph.

Nodes can calculate their value automatically based on other nondes.

Implementations§

Source§

impl<C: Calc> Node<C>
where C::Value: Clone,

Source

pub fn get_mut(&mut self) -> C::Value

Returns the node’s value, recalculating it if needed.

Source§

impl<C: Calc> Node<C>

Source

pub fn shared(self) -> SharedNode<C>

Wraps this node so that it can be used as an input to two or more dependent nodes.

Source§

impl<C: Calc + Send + 'static> Node<C>

Source

pub fn boxed(self) -> BoxNode<C::Value>

Wraps this node so that its Calc type is hidden.

Boxing is needed when:

  • you need to write the type of the node, but you can’t write the name of the concrete Calc type (for instance, it’s a func node involving a closure)
  • you have a choice of types for a node (for instance, if a { a_node.boxed() } else { b_node.boxed() })
Source§

impl<C: Calc> Node<Arc<Mutex<RawMutex, C>>>

Source

pub fn get(&self) -> C::Value

Returns the shared node’s value, recalculating it if needed.

Source§

impl<T: Clone> Node<Const<T>>

Source

pub fn get(&self) -> T

Returns the const node’s value.

Source§

impl<T: Clone> Node<Source<T>>

Source

pub fn get(&self) -> T

Returns the source node’s value.

Source§

impl<T> Node<Source<T>>

Source

pub fn update(&self, updater: impl FnOnce(&mut T) -> bool)

Changes the value held within the source node based on the current value.

Source

pub fn set(&self, value: T)

Replaces the value held within the source node.

Source§

impl<C: Calc> Node<C>

Source

pub fn inspect<F: FnMut(&C::Value)>(self, f: F) -> Node<Inspect<C, F>>

Wraps the node with a function, whicih can inspect the node’s value each time it is calculated.

Source§

impl<C1: Calc> Node<C1>

Source

pub fn map<T, F: FnMut(C1::Value) -> T>(self, f: F) -> Node<Func1<C1, T, F>>

Returns a new node whose value is calculated from this node.

Source

pub fn map_update<T, F: FnMut(&mut T, C1::Value) -> bool>( self, initial_value: T, f: F, ) -> Node<Update1<C1, T, F>>

Returns a new node whose value is calculated from this node. The FnMut that performs the calculation can update the value in place.

Source§

impl<C1: Calc> Node<C1>

Source

pub fn zip<C2: Calc, T, F: FnMut(C1::Value, C2::Value) -> T>( self, prec2: Node<C2>, f: F, ) -> Node<Func2<C1, C2, T, F>>

Returns a new node whose value is calculated from this node and another node.

Source

pub fn zip_update<C2: Calc, T, F: FnMut(&mut T, C1::Value, C2::Value) -> bool>( self, prec2: Node<C2>, initial_value: T, f: F, ) -> Node<Update2<C1, C2, T, F>>

Returns a new node whose value is calculated from this node and another node. The FnMut that performs the calculation can update the value in place.

Source§

impl<C1: Calc> Node<C1>

Source

pub fn zip3<C2: Calc, C3: Calc, T, F: FnMut(C1::Value, C2::Value, C3::Value) -> T>( self, prec2: Node<C2>, prec3: Node<C3>, f: F, ) -> Node<Func3<C1, C2, C3, T, F>>

Returns a new node whose value is calculated from this node and 2 other nodes.

Source

pub fn zip3_update<C2: Calc, C3: Calc, T, F: FnMut(&mut T, C1::Value, C2::Value, C3::Value) -> bool>( self, prec2: Node<C2>, prec3: Node<C3>, initial_value: T, f: F, ) -> Node<Update3<C1, C2, C3, T, F>>

Returns a new node whose value is calculated from this node and 2 other nodes. The FnMut that performs the calculation can update the value in place.

Source§

impl<C1: Calc> Node<C1>

Source

pub fn zip4<C2: Calc, C3: Calc, C4: Calc, T, F: FnMut(C1::Value, C2::Value, C3::Value, C4::Value) -> T>( self, prec2: Node<C2>, prec3: Node<C3>, prec4: Node<C4>, f: F, ) -> Node<Func4<C1, C2, C3, C4, T, F>>

Returns a new node whose value is calculated from this node and 3 other nodes.

Source

pub fn zip4_update<C2: Calc, C3: Calc, C4: Calc, T, F: FnMut(&mut T, C1::Value, C2::Value, C3::Value, C4::Value) -> bool>( self, prec2: Node<C2>, prec3: Node<C3>, prec4: Node<C4>, initial_value: T, f: F, ) -> Node<Update4<C1, C2, C3, C4, T, F>>

Returns a new node whose value is calculated from this node and 3 other nodes. The FnMut that performs the calculation can update the value in place.

Source§

impl<C1: Calc> Node<C1>

Source

pub fn zip5<C2: Calc, C3: Calc, C4: Calc, C5: Calc, T, F: FnMut(C1::Value, C2::Value, C3::Value, C4::Value, C5::Value) -> T>( self, prec2: Node<C2>, prec3: Node<C3>, prec4: Node<C4>, prec5: Node<C5>, f: F, ) -> Node<Func5<C1, C2, C3, C4, C5, T, F>>

Returns a new node whose value is calculated from this node and 4 other nodes.

Source

pub fn zip5_update<C2: Calc, C3: Calc, C4: Calc, C5: Calc, T, F: FnMut(&mut T, C1::Value, C2::Value, C3::Value, C4::Value, C5::Value) -> bool>( self, prec2: Node<C2>, prec3: Node<C3>, prec4: Node<C4>, prec5: Node<C5>, initial_value: T, f: F, ) -> Node<Update5<C1, C2, C3, C4, C5, T, F>>

Returns a new node whose value is calculated from this node and 4 other nodes. The FnMut that performs the calculation can update the value in place.

Source§

impl<C1: Calc> Node<C1>

Source

pub fn zip6<C2: Calc, C3: Calc, C4: Calc, C5: Calc, C6: Calc, T, F: FnMut(C1::Value, C2::Value, C3::Value, C4::Value, C5::Value, C6::Value) -> T>( self, prec2: Node<C2>, prec3: Node<C3>, prec4: Node<C4>, prec5: Node<C5>, prec6: Node<C6>, f: F, ) -> Node<Func6<C1, C2, C3, C4, C5, C6, T, F>>

Returns a new node whose value is calculated from this node and 5 other nodes.

Source

pub fn zip6_update<C2: Calc, C3: Calc, C4: Calc, C5: Calc, C6: Calc, T, F: FnMut(&mut T, C1::Value, C2::Value, C3::Value, C4::Value, C5::Value, C6::Value) -> bool>( self, prec2: Node<C2>, prec3: Node<C3>, prec4: Node<C4>, prec5: Node<C5>, prec6: Node<C6>, initial_value: T, f: F, ) -> Node<Update6<C1, C2, C3, C4, C5, C6, T, F>>

Returns a new node whose value is calculated from this node and 5 other nodes. The FnMut that performs the calculation can update the value in place.

Source§

impl<C1: Calc> Node<C1>

Source

pub fn zip7<C2: Calc, C3: Calc, C4: Calc, C5: Calc, C6: Calc, C7: Calc, T, F: FnMut(C1::Value, C2::Value, C3::Value, C4::Value, C5::Value, C6::Value, C7::Value) -> T>( self, prec2: Node<C2>, prec3: Node<C3>, prec4: Node<C4>, prec5: Node<C5>, prec6: Node<C6>, prec7: Node<C7>, f: F, ) -> Node<Func7<C1, C2, C3, C4, C5, C6, C7, T, F>>

Returns a new node whose value is calculated from this node and 6 other nodes.

Source

pub fn zip7_update<C2: Calc, C3: Calc, C4: Calc, C5: Calc, C6: Calc, C7: Calc, T, F: FnMut(&mut T, C1::Value, C2::Value, C3::Value, C4::Value, C5::Value, C6::Value, C7::Value) -> bool>( self, prec2: Node<C2>, prec3: Node<C3>, prec4: Node<C4>, prec5: Node<C5>, prec6: Node<C6>, prec7: Node<C7>, initial_value: T, f: F, ) -> Node<Update7<C1, C2, C3, C4, C5, C6, C7, T, F>>

Returns a new node whose value is calculated from this node and 6 other nodes. The FnMut that performs the calculation can update the value in place.

Source§

impl<C1: Calc> Node<C1>

Source

pub fn zip8<C2: Calc, C3: Calc, C4: Calc, C5: Calc, C6: Calc, C7: Calc, C8: Calc, T, F: FnMut(C1::Value, C2::Value, C3::Value, C4::Value, C5::Value, C6::Value, C7::Value, C8::Value) -> T>( self, prec2: Node<C2>, prec3: Node<C3>, prec4: Node<C4>, prec5: Node<C5>, prec6: Node<C6>, prec7: Node<C7>, prec8: Node<C8>, f: F, ) -> Node<Func8<C1, C2, C3, C4, C5, C6, C7, C8, T, F>>

Returns a new node whose value is calculated from this node and 7 other nodes.

Source

pub fn zip8_update<C2: Calc, C3: Calc, C4: Calc, C5: Calc, C6: Calc, C7: Calc, C8: Calc, T, F: FnMut(&mut T, C1::Value, C2::Value, C3::Value, C4::Value, C5::Value, C6::Value, C7::Value, C8::Value) -> bool>( self, prec2: Node<C2>, prec3: Node<C3>, prec4: Node<C4>, prec5: Node<C5>, prec6: Node<C6>, prec7: Node<C7>, prec8: Node<C8>, initial_value: T, f: F, ) -> Node<Update8<C1, C2, C3, C4, C5, C6, C7, C8, T, F>>

Returns a new node whose value is calculated from this node and 7 other nodes. The FnMut that performs the calculation can update the value in place.

Trait Implementations§

Source§

impl<C: Clone> Clone for Node<C>

Source§

fn clone(&self) -> Node<C>

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

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<C> Freeze for Node<C>
where C: Freeze,

§

impl<C> !RefUnwindSafe for Node<C>

§

impl<C> Send for Node<C>
where C: Send,

§

impl<C> Sync for Node<C>
where C: Sync,

§

impl<C> Unpin for Node<C>
where C: Unpin,

§

impl<C> !UnwindSafe for Node<C>

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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.
Source§

impl<T> Erased for T