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>
impl<M: INotifyPropertyChanged + 'static, V: 'static> PropertyPath<Rc<M>, V>
Sourcepub fn property(
name: impl Into<String>,
get: impl Fn(&Rc<M>) -> V + 'static,
) -> Self
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>>
impl<M: INotifyPropertyChanged + 'static, V: 'static> PropertyPath<Option<Rc<M>>, Option<V>>
Sourcepub fn optional_property(
name: impl Into<String>,
get: impl Fn(&Rc<M>) -> V + 'static,
) -> Self
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>>
impl<M: INotifyPropertyChanged + 'static, V: 'static> PropertyPath<Option<Rc<M>>, Option<V>>
Sourcepub fn optional_property_and_then(
name: impl Into<String>,
get: impl Fn(&Rc<M>) -> Option<V> + 'static,
) -> Self
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>
impl<M: 'static, V: 'static> PropertyPath<Rc<M>, V>
Sourcepub fn object_property(
name: impl Into<String>,
get: impl Fn(&Rc<M>) -> V + 'static,
) -> Self
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>
impl<S: 'static, V: 'static> PropertyPath<S, V>
Sourcepub 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
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.
Sourcepub fn value(name: impl Into<String>, get: impl Fn(&S) -> V + 'static) -> Self
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.
Sourcepub fn steps(&self) -> &[PathStep]
pub fn steps(&self) -> &[PathStep]
The steps of the path, type-erased, in order (the member accesses of the expression).
Sourcepub fn names(&self) -> &[String]
pub fn names(&self) -> &[String]
The names of the properties along the path (the member names of the expression).
Sourcepub fn observe(&self, source: &S, changed: Rc<dyn Fn()>) -> Rc<dyn IDisposable>
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.
Sourcepub fn then<W: 'static>(self, next: PropertyPath<V, W>) -> PropertyPath<S, W>
pub fn then<W: 'static>(self, next: PropertyPath<V, W>) -> PropertyPath<S, W>
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>>
impl<S: Clone + 'static, M: INotifyPropertyChanged + 'static> PropertyPath<S, Rc<M>>
Sourcepub fn then_property<W: 'static>(
self,
name: impl Into<String>,
get: impl Fn(&Rc<M>) -> W + 'static,
) -> PropertyPath<S, W>
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>>>
impl<S: Clone + 'static, M: INotifyPropertyChanged + 'static> PropertyPath<S, Option<Rc<M>>>
Sourcepub fn then_optional_property<W: 'static>(
self,
name: impl Into<String>,
get: impl Fn(&Rc<M>) -> W + 'static,
) -> PropertyPath<S, Option<W>>
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>>>
impl<S: Clone + 'static, M: INotifyPropertyChanged + 'static> PropertyPath<S, Option<Rc<M>>>
Sourcepub 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>>
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()).