Skip to main content

PropertyPath

Struct PropertyPath 

Source
pub struct PropertyPath<S, V> { /* private fields */ }
Expand description

A typed path from an object to a value through its properties (Expression<Func<S, V>>).

Implementations§

Source§

impl<M: INotifyPropertyChanged + 'static, V: 'static> PropertyPath<Rc<M>, V>

Source

pub fn property( name: impl Into<String>, get: impl Fn(&Rc<M>) -> V + 'static, ) -> Self

A path of one property of an object that raises PropertyChanged: a change of name, or of every property (an empty name), changes the value.

Its step gives the object as its owner, with its change notification.

Source§

impl<M: INotifyPropertyChanged + 'static, V: 'static> PropertyPath<Option<Rc<M>>, Option<V>>

Source

pub fn optional_property( name: impl Into<String>, get: impl Fn(&Rc<M>) -> V + 'static, ) -> Self

A path of one property of an object that may be absent (x => x.Child.Name where Child may be null): None while there is no object, otherwise the property, observed as property observes it.

Its step gives the object as its owner when there is one, and an empty owner otherwise.

Source§

impl<M: INotifyPropertyChanged + 'static, V: 'static> PropertyPath<Option<Rc<M>>, Option<V>>

Source

pub fn optional_property_and_then( name: impl Into<String>, get: impl Fn(&Rc<M>) -> Option<V> + 'static, ) -> Self

optional_property of a property that may itself be absent (x => x.A.B.C where A and B may be null): the value is None while there is no object or while the property is None, so the steps of a path of absent objects do not nest their Options.

Source§

impl<M: 'static, V: 'static> PropertyPath<Rc<M>, V>

Source

pub fn object_property( name: impl Into<String>, get: impl Fn(&Rc<M>) -> V + 'static, ) -> Self

A path of one property of an object that does not raise PropertyChanged itself, but whose changes an observer chosen at run time may see (an object of a user-interface framework, through its own property system).

Its step gives the object (the Rc of the source) as its owner, without a change notification, so that the observer with the highest affinity for that object observes the property. The path itself observes nothing, as value does.

Source§

impl<S: 'static, V: 'static> PropertyPath<S, V>

Source

pub fn owned_property( name: impl Into<String>, get: impl Fn(&S) -> V + 'static, owner: impl Fn(&S) -> PropertyOwner + 'static, observe: impl Fn(&S, Rc<dyn Fn()>) -> Rc<dyn IDisposable> + 'static, ) -> Self

A path of one property whose owner and observation the caller gives: owner gives the object that owns the property from the source of the step (what an observer chosen at run time sees), and observe runs its callback when the value may have changed, until the result is disposed.

It is how a framework whose objects are not Rcs of a type that raises PropertyChanged (handles of the objects of a user interface) writes the steps of its properties.

Source

pub fn value(name: impl Into<String>, get: impl Fn(&S) -> V + 'static) -> Self

A path of one value that does not notify its changes (a plain field, or an object that is not INotifyPropertyChanged): it is read again only when an earlier step changes.

Its step cannot give the object that owns the value (the source is not cloned), so its owner is empty: an observer chosen at run time sees a value that does not notify.

Source

pub fn steps(&self) -> &[PathStep]

The steps of the path, type-erased, in order (the member accesses of the expression).

Source

pub fn names(&self) -> &[String]

The names of the properties along the path (the member names of the expression).

Source

pub fn path(&self) -> String

The path as text, Address.Street.

Source

pub fn get(&self, source: &S) -> V

The value of the path on source (the compiled expression).

Source

pub fn getter(&self) -> Rc<dyn Fn(&S) -> V>

The getter of the path.

Source

pub fn observe(&self, source: &S, changed: Rc<dyn Fn()>) -> Rc<dyn IDisposable>

Runs changed whenever the value of the path on source may have changed, until the result is disposed.

Source

pub fn then<W: 'static>(self, next: PropertyPath<V, W>) -> PropertyPath<S, W>
where S: Clone, V: Clone,

The path that continues with next from the value of this one (x => x.A.B): when the object of this step changes, the steps of next are observed on the new object.

Source§

impl<S: Clone + 'static, M: INotifyPropertyChanged + 'static> PropertyPath<S, Rc<M>>

Source

pub fn then_property<W: 'static>( self, name: impl Into<String>, get: impl Fn(&Rc<M>) -> W + 'static, ) -> PropertyPath<S, W>

then with one property of the object of this path (PropertyPath::property); the object’s type comes from this path.

Source§

impl<S: Clone + 'static, M: INotifyPropertyChanged + 'static> PropertyPath<S, Option<Rc<M>>>

Source

pub fn then_optional_property<W: 'static>( self, name: impl Into<String>, get: impl Fn(&Rc<M>) -> W + 'static, ) -> PropertyPath<S, Option<W>>

then with one property of the object of this path, which may be absent (PropertyPath::optional_property): the value is None while there is no object.

Source§

impl<S: Clone + 'static, M: INotifyPropertyChanged + 'static> PropertyPath<S, Option<Rc<M>>>

Source

pub fn then_optional_property_and_then<W: 'static>( self, name: impl Into<String>, get: impl Fn(&Rc<M>) -> Option<W> + 'static, ) -> PropertyPath<S, Option<W>>

then with a property of the object of this path that may itself be absent (PropertyPath::optional_property_and_then): x => x.A.B.C where each object may be null is prop!(X => a).then_optional_property_and_then("B", |a| a.b()).then_optional_property("C", |b| b.c()).

Trait Implementations§

Source§

impl<S, V> Clone for PropertyPath<S, V>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<S, V> !RefUnwindSafe for PropertyPath<S, V>

§

impl<S, V> !Send for PropertyPath<S, V>

§

impl<S, V> !Sync for PropertyPath<S, V>

§

impl<S, V> !UnwindSafe for PropertyPath<S, V>

§

impl<S, V> Freeze for PropertyPath<S, V>
where Rc<dyn Fn(&S) -> V>: Freeze, Rc<dyn Fn(&S, Rc<dyn Fn()>) -> Rc<dyn IDisposable>>: Freeze,

§

impl<S, V> Unpin for PropertyPath<S, V>
where Rc<dyn Fn(&S) -> V>: Unpin, Rc<dyn Fn(&S, Rc<dyn Fn()>) -> Rc<dyn IDisposable>>: Unpin,

§

impl<S, V> UnsafeUnpin for PropertyPath<S, V>
where Rc<dyn Fn(&S) -> V>: UnsafeUnpin, Rc<dyn Fn(&S, Rc<dyn Fn()>) -> Rc<dyn IDisposable>>: 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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.