pub struct Backlink<'a, T>(/* private fields */);
Expand description
A backlink to a node
Methods from Deref<Target = Node<T>>§
Sourcepub fn data(&self) -> View<RwLockReadGuard<'_, T>>
pub fn data(&self) -> View<RwLockReadGuard<'_, T>>
Read the data associated with a rain
node
Sourcepub fn try_data(&self) -> Option<View<RwLockReadGuard<'_, T>>>
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!");
Sourcepub fn data_mut(&self) -> View<RwLockWriteGuard<'_, T>>
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)
Sourcepub fn try_data_mut(&self) -> Option<View<RwLockWriteGuard<'_, T>>>
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!");
Trait Implementations§
Auto Trait Implementations§
impl<'a, T> Freeze for Backlink<'a, T>
impl<'a, T> !RefUnwindSafe for Backlink<'a, T>
impl<'a, T> Send for Backlink<'a, T>
impl<'a, T> Sync for Backlink<'a, T>
impl<'a, T> Unpin for Backlink<'a, T>
impl<'a, T> !UnwindSafe for Backlink<'a, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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