Struct Property

Source
pub struct Property<T> { /* private fields */ }

Implementations§

Source§

impl<T: 'static + Clone + PartialEq> Property<T>

Source

pub fn new<U: Into<T>>(val: U) -> Self

Source

pub fn binded_from(src_property: &Property<T>) -> Self

Source

pub fn binded_c_from<TSrc: 'static + Clone + PartialEq, F: 'static + Fn(TSrc) -> T>( src_property: &Property<TSrc>, f: F, ) -> Self

Source

pub fn binded_to(dst_property: &Property<T>, init_value: T) -> Self

Source

pub fn binded_c_to<TDst: 'static + Clone + PartialEq, F: 'static + Fn(T) -> TDst>( dst_property: &Property<TDst>, f: F, init_value: T, ) -> Self

Source

pub fn binded_two_way(other_property: &Property<T>) -> Self

Source

pub fn binded_c_two_way<TOther, F1, F2>( other_property: &Property<TOther>, f1: F1, f2: F2, ) -> Self
where TOther: 'static + Clone + PartialEq, F1: 'static + Fn(TOther) -> T, F2: 'static + Fn(T) -> TOther,

Source

pub fn set(&self, val: T)

Source

pub fn change<F: 'static + Fn(T) -> T>(&self, f: F)

Source

pub fn get(&self) -> T

Source

pub fn bind(&self, src_property: &Property<T>)

Source

pub fn bind_c<TSrc: 'static + Clone + PartialEq, F: 'static + Fn(TSrc) -> T>( &self, src_property: &Property<TSrc>, f: F, )

Source

pub fn on_changed<F: 'static + FnMut(T)>(&self, f: F) -> Subscription

Trait Implementations§

Source§

impl<T: 'static + Clone + PartialEq> Clone for Property<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<V> From<&Property<Option<Rc<V>>>> for Box<dyn ObservableCollection<Rc<RefCell<dyn ControlObject>>>>
where V: 'static + ViewModel + PartialEq,

Source§

fn from(src: &Property<Option<Rc<V>>>) -> Self

Converts to this type from the input type.
Source§

impl From<&Property<Rc<RefCell<dyn ControlObject>>>> for Box<dyn ObservableCollection<Rc<RefCell<dyn ControlObject>>>>

Converts Property to observable collection.

Source§

fn from(src: &Property<Rc<RefCell<dyn ControlObject>>>) -> Self

Converts to this type from the input type.
Source§

impl<V> From<&Property<Rc<V>>> for Box<dyn ObservableCollection<Rc<RefCell<dyn ControlObject>>>>
where V: 'static + ViewModel + PartialEq,

Source§

fn from(src: &Property<Rc<V>>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<&Property<T>> for Property<T>
where T: 'static + Clone + PartialEq,

Allows to easily write one-way binding.

Example:

ui! { Control { text_property: &vm.text }}

Source§

fn from(value: &Property<T>) -> Property<T>

Converts to this type from the input type.
Source§

impl<T> From<&mut Property<T>> for Property<T>
where T: 'static + Clone + PartialEq,

Allows to easily write two-way bindings.

Example:

ui! { Control { text_property: &mut vm.text }}

Source§

fn from(value: &mut Property<T>) -> Property<T>

Converts to this type from the input type.
Source§

impl<TSrc, TDest, F> From<(&Property<TSrc>, F)> for Property<TDest>
where TSrc: 'static + Clone + PartialEq, TDest: 'static + Clone + PartialEq, F: 'static + Fn(TSrc) -> TDest,

Allows to easily write one-way binding with converter.

Example:

ui! { Control { text_property: (&vm.count, |c| c.to_string()) }}

Source§

fn from(value: (&Property<TSrc>, F)) -> Property<TDest>

Converts to this type from the input type.
Source§

impl<TSrc, TDest, F1, F2> From<(&mut Property<TSrc>, F1, F2)> for Property<TDest>
where TSrc: 'static + Clone + PartialEq, TDest: 'static + Clone + PartialEq, F1: 'static + Fn(TSrc) -> TDest, F2: 'static + Fn(TDest) -> TSrc,

Allows to easily write two-way binding with converter.

Example:

ui! { Control { text_property: (&mut vm.count, |c| c.to_string(), |c| c.parse().unwrap()) }}

Source§

fn from(value: (&mut Property<TSrc>, F1, F2)) -> Property<TDest>

Converts to this type from the input type.
Source§

impl<T, U> From<U> for Property<T>
where T: 'static + Clone + PartialEq, U: Into<T> + IntoProperty,

Allows to convert types attributed with IntoProperty to Property.

Cannot do it for all types at once, because then there is a conflict with binding conversions (tuples and properties used as source).

Example:

ui! { Control { int_property: 10, text_property: “My Text” }}

Source§

fn from(value: U) -> Property<T>

Converts to this type from the input type.
Source§

impl<T> ObservableCollection<T> for Property<Option<T>>
where T: 'static + Clone + PartialEq,

Source§

fn len(&self) -> usize

Source§

fn get(&self, index: usize) -> Option<T>

Source§

fn on_changed(&self, f: Box<dyn FnMut(VecDiff<T>)>) -> Option<Subscription>

Source§

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

ObservableCollection for Property.

Source§

fn len(&self) -> usize

Source§

fn get(&self, index: usize) -> Option<T>

Source§

fn on_changed(&self, f: Box<dyn FnMut(VecDiff<T>)>) -> Option<Subscription>

Auto Trait Implementations§

§

impl<T> Freeze for Property<T>

§

impl<T> RefUnwindSafe for Property<T>

§

impl<T> !Send for Property<T>

§

impl<T> !Sync for Property<T>

§

impl<T> Unpin for Property<T>

§

impl<T> UnwindSafe for Property<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> CloneAny for T
where T: Any + Clone,

Source§

fn clone_any(&self) -> Box<dyn CloneAny>

Source§

fn clone_any_send(&self) -> Box<dyn CloneAny + Send>
where T: Send,

Source§

fn clone_any_sync(&self) -> Box<dyn CloneAny + Sync>
where T: Sync,

Source§

fn clone_any_send_sync(&self) -> Box<dyn CloneAny + Send + Sync>
where T: Send + Sync,

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, TSrcColl> ObservableCollectionExt<T> for TSrcColl
where T: 'static + Clone, TSrcColl: ObservableCollection<T> + 'static,

Source§

fn map<TDst, F>(&self, f: F) -> ObservableCollectionMap<TDst>
where TDst: 'static + Clone, F: 'static + Fn(&T) -> TDst,

Map creates new observable collection.

It keeps mapped copy of every item.

The only connection between it and original observable collection is by subscribing on the on_changed event of the source collection, so we don’t have to keep implicit reference to the source collection. The on_change event of source collection keeps a weak reference to our handler.

Source§

impl<TSrc, TSrcColl> ObservableCollectionFlatMapExt<TSrc> for TSrcColl
where TSrc: Clone + 'static, TSrcColl: ObservableCollection<TSrc> + 'static,

Source§

fn flat_map<TDst, TDstColl, F>(&self, f: F) -> ObservableCollectionFlatMap<TDst>
where TDst: Clone + 'static, TDstColl: ObservableCollection<TDst> + IntoIterator<Item = TDst>, F: FnMut(&TSrc) -> TDstColl + 'static,

Flat map creates new observable collection.

It keeps mapped copy of every item.

The only connection between it and original observable collection is by subscribing on the on_changed event of the source collection, so we don’t have to keep implicit reference to the source collection. The on_change event of source collection keeps a weak reference to our handler.

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

impl<T> UnsafeAny for T
where T: Any,