[][src]Struct rt_graph::observable_value::ObservableValue

pub struct ObservableValue<T> where
    T: Clone
{ /* fields omitted */ }

A value that implements the Observer pattern.

Consumers can connect to receive callbacks when the value changes.

Implementations

impl<T> ObservableValue<T> where
    T: Clone
[src]

pub fn new(initial_value: T) -> ObservableValue<T>[src]

Construct an ObservableValue.

pub fn get(&self) -> &T[src]

Get the current value

pub fn set(&mut self, new_value: &T)[src]

Set a new value and notify all connected subscribers.

pub fn connect<F>(&mut self, callback: F) -> SubscriptionId where
    F: Fn(&T) + 'static, 
[src]

Connect a new subscriber that will receive callbacks when the value is set.

Returns a SubscriptionId to disconnect the subscription when no longer required.

pub fn disconnect(&mut self, sub_id: SubscriptionId)[src]

Disconnect an existing subscription.

pub fn split(self) -> (ReadHalf<T>, WriteHalf<T>)[src]

Divide this instance into a read half (can listen for updates, but cannot write new values) and a write half (can write new values).

Auto Trait Implementations

impl<T> !RefUnwindSafe for ObservableValue<T>

impl<T> !Send for ObservableValue<T>

impl<T> !Sync for ObservableValue<T>

impl<T> Unpin for ObservableValue<T> where
    T: Unpin

impl<T> !UnwindSafe for ObservableValue<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,