Shared

Struct Shared 

Source
pub struct Shared<T: 'static, B: 'static> {
    pub id: Option<usize>,
    /* private fields */
}
Expand description

A hook to a shared_value.

This is generally created by calling use_rw or use_w on a shareable!, or by calling ListEntry::use_rw or ListEntry::use_w.

Fields§

§id: Option<usize>

Implementations§

Source§

impl<T: 'static, B: 'static + Flag> Shared<T, B>

Source

pub fn init<'a, P, F: FnOnce() -> T>( cx: &Scope<'a, P>, opt: &mut Shareable<T>, f: F, _: B, ) -> &'a mut Self

Initialize the hook in scope cx.

The shared value will be initialized with f() if it hasn’t been created yet.

NOTE: this method should generally not be used directly; instead, shared values are usually created with shareable!.

Source

pub fn write(&self) -> MappedRwLockWriteGuard<'_, T>

Obtain a write pointer to the shared value and register the change.

This will mark all components which hold a RW link to the value as needing update.

Source

pub fn write_silent(&self) -> MappedRwLockWriteGuard<'_, T>

Obtain a write pointer to the shared value but do not register the change.

This will not notify consumers of the change to the value.

Source

pub fn needs_update(&self)

Mark the components which hold a RW link to the value as needing update.

Source

pub fn set(&self, t: T)
where T: PartialEq,

Set the shared value.

This marks compoments which hold a RW link to the value as needing update if and only if the value has changed.

Source

pub fn set_with<F: Fn(&T) -> T>(&self, f: F)
where T: PartialEq,

Set the shared value to f(&x) where x is the current value.

This marks components which hold a RW link to the value as needing update if and only if the value has changed.

Source

pub fn read(&self) -> MappedRwLockReadGuard<'_, T>

Get the value of the shared data.

Source

pub fn listeners(&self) -> String

Trait Implementations§

Source§

impl<T: 'static, B: 'static> Clone for Shared<T, B>

Source§

fn clone(&self) -> Self

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: 'static, B: 'static> Drop for Shared<T, B>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T, B> Freeze for Shared<T, B>

§

impl<T, B> !RefUnwindSafe for Shared<T, B>

§

impl<T, B> Send for Shared<T, B>
where B: Send, T: Send + Sync,

§

impl<T, B> Sync for Shared<T, B>
where B: Sync, T: Send + Sync,

§

impl<T, B> Unpin for Shared<T, B>
where B: Unpin,

§

impl<T, B> !UnwindSafe for Shared<T, B>

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> 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.