Skip to main content

Property

Struct Property 

Source
pub struct Property<T>
where T: 'static + Clone,
{ /* private fields */ }
Expand description

Property represents a storage which may receive new values via it’s slot and may notify about value change via it’s signal.

It’s important that Property::try_update method have to be called to initiate slot data processing.

Implementations§

Source§

impl<T> Property<T>
where T: 'static + Clone,

Source

pub fn new(value: T) -> Property<T>

Creates new property instance.

Source

pub fn signal(&mut self) -> &mut Signal<T>

Signal will be emited at least every time inner value will be changed

It’s possible that signal may be emited with the same value.

Source

pub fn slot(&self) -> &dyn Slot<T>

The slot allows value change to be scheduled.

The value will not be changed without (Property::try_update) call. Only after that the value will be update and signal will be emited.

Source

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

Sets new value. Signal will be emited to inform about value change.

Source

pub fn as_ref(&self) -> &T

Allow access to property’s value via immutable ref

Source

pub fn for_mut(&mut self, f: &dyn Fn(&mut T))

Allow function to be change inner value. Signal will be rased to inform about value change even if value is the same.

Source

pub fn try_update(&mut self) -> bool

Initiates inner value update from slot’s data. Signal will be emited for every incoming slot data.

return true if there was at least one update from slot, otherwise return false

Trait Implementations§

Source§

impl<T> Default for Property<T>
where T: 'static + Clone + Default,

Source§

fn default() -> Property<T>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for Property<T>

§

impl<T> !Send for Property<T>

§

impl<T> !Sync for Property<T>

§

impl<T> !UnwindSafe for Property<T>

§

impl<T> Freeze for Property<T>
where T: Freeze,

§

impl<T> Unpin for Property<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Property<T>
where T: UnsafeUnpin,

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