Struct Node

Source
pub struct Node<T: ?Sized> { /* private fields */ }
Expand description

A node in a rain graph

Implementations§

Source§

impl<T: ?Sized> Node<T>

Source

pub fn data(&self) -> View<RwLockReadGuard<'_, T>>

Read the data associated with a rain node

Source

pub fn try_data(&self) -> Option<View<RwLockReadGuard<'_, T>>>

Try to read the data associated with a rain node. Return None if the data is currently unavailable to read, i.e. there is a write occuring

use std::ops::Deref;
use rain_lang::graph::node::{Node, Data};
let node = Node::new(Data(true));
{
    let read = node.data();
    assert_eq!(read.deref(), &Data(true));
    let try_read = node.try_data().expect("Multiple reads are allowed!");
    assert_eq!(try_read.deref(), &Data(true));
}
let mut write = node.data_mut();
*write = Data(false);
assert_eq!(write.deref(), &Data(false));
assert!(node.try_data().is_none(), "Concurrent reads and writes are not allowed!");
Source

pub fn data_mut(&self) -> View<RwLockWriteGuard<'_, T>>

Mutably get the data associated with a rain node. Note mutation is limited to operations which will not corrupt the rain graph (e.g. adding dependencies)

Source

pub fn try_data_mut(&self) -> Option<View<RwLockWriteGuard<'_, T>>>

Try to mutably get the data associated with a rain node Return None if the data is currently unavailable to write

use std::ops::Deref;
use rain_lang::graph::node::{Node, Data};
let node = Node::new(Data(true));
{
    let mut try_write = node.try_data_mut().expect("Valid write");
    *try_write = Data(false);
}
let read = node.data();
assert_eq!(read.deref(), &Data(false));
let try_read = node.try_data().expect("Multiple reads are allowed!");
assert_eq!(try_read.deref(), &Data(false));
assert!(node.try_data_mut().is_none(), "Concurrent reads and writes are not allowed!");
Source

pub fn downgrade(&self) -> WeakNode<T>

Downgrade this node to a weak handle

Source§

impl<T: NodeData> Node<T>

Source

pub fn try_new(data: T) -> Result<Node<T>, T::Error>

Try to create a new node from given data, which can fail

Source§

impl<T: NodeData<Error = Infallible>> Node<T>

Source

pub fn new(data: T) -> Node<T>

Try to create a new node from given data, which cannot fail

Source§

impl Node<ValueData>

Source

pub fn add_dependent(&self, dependent: WeakId)

Register a value dependent on this value

Trait Implementations§

Source§

impl<T: ?Sized> Clone for Node<T>

Source§

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

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

impl<T: Debug + ?Sized> Debug for Node<T>

Source§

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

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

impl<T: Display> Display for Node<T>

Source§

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

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

impl<T> HasAddr<T> for Node<T>

Source§

fn addr(&self) -> Cow<'_, Node<T>>

Get a Cow of the strong node address associated with this value
Source§

impl<T> HasThis<T> for Node<T>

Source§

fn this(&self) -> Cow<'_, WeakNode<T>>

Get a Cow of the weak node address associated with this value. May be null if there is none.
Source§

impl<T: ?Sized> Hash for Node<T>

Source§

fn hash<H: Hasher>(&self, hasher: &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 JEq<Node<ValueData>> for Binary

Source§

fn jeq(&self, v: &ValId) -> bool

Check whether two objects are judgementally equal
Source§

impl JEq<Node<ValueData>> for Bool

Source§

fn jeq(&self, v: &ValId) -> bool

Check whether two objects are judgementally equal
Source§

impl JEq<Node<ValueData>> for Lambda

Source§

fn jeq(&self, v: &ValId) -> bool

Check whether two objects are judgementally equal
Source§

impl JEq<Node<ValueData>> for LogicalOp

Source§

fn jeq(&self, v: &ValId) -> bool

Check whether two objects are judgementally equal
Source§

impl JEq<Node<ValueData>> for Parameter

Source§

fn jeq(&self, v: &ValId) -> bool

Check whether two objects are judgementally equal
Source§

impl JEq<Node<ValueData>> for Sexpr

Source§

fn jeq(&self, v: &ValId) -> bool

Check whether two objects are judgementally equal
Source§

impl JEq<Node<ValueData>> for Unary

Source§

fn jeq(&self, v: &ValId) -> bool

Check whether two objects are judgementally equal
Source§

impl JEq<Node<ValueData>> for Unit

Source§

fn jeq(&self, v: &ValId) -> bool

Check whether two objects are judgementally equal
Source§

impl JEq<Node<ValueData>> for ValueEnum

Source§

fn jeq(&self, other: &ValId) -> bool

Check whether two objects are judgementally equal
Source§

impl JEq<Node<ValueData>> for bool

Source§

fn jeq(&self, v: &ValId) -> bool

Check whether two objects are judgementally equal
Source§

impl<T: ?Sized> PartialEq for Node<T>

Source§

fn eq(&self, other: &Node<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: ?Sized> Eq for Node<T>

Auto Trait Implementations§

§

impl<T> Freeze for Node<T>
where T: ?Sized,

§

impl<T> !RefUnwindSafe for Node<T>

§

impl<T> Send for Node<T>
where T: Send + Sync + ?Sized,

§

impl<T> Sync for Node<T>
where T: Send + Sync + ?Sized,

§

impl<T> Unpin for Node<T>
where T: ?Sized,

§

impl<T> !UnwindSafe for Node<T>

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V