PropertyPath
struct · ferroui-system · v0.5.0
struct PropertyPath<S, V>
A typed path from an object to a value through its properties (Expression<Func<S, V>>).
Members
propertyoptional_propertyoptional_property_and_thenobject_propertyowned_propertyvaluestepsnamespathgetgetterobservethenthen_propertythen_optional_propertythen_optional_property_and_then
property
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.
optional_property
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.
optional_property_and_then
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.
object_property
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.
owned_property
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.
value
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.
steps
fn steps(self: &Self) -> &[PathStep]
The steps of the path, type-erased, in order (the member accesses of the expression).
names
fn names(self: &Self) -> &[String]
The names of the properties along the path (the member names of the expression).
path
fn path(self: &Self) -> String
The path as text, Address.Street.
get
fn get(self: &Self, source: &S) -> V
The value of the path on source (the compiled expression).
getter
fn getter(self: &Self) -> Rc<dyn Fn(&S) -> V>
The getter of the path.
observe
fn observe(self: &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.
then
fn then<W: 'static>(self: 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.
then_property
fn then_property<W: 'static>(self: 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.
then_optional_property
fn then_optional_property<W: 'static>(self: 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.
then_optional_property_and_then
fn then_optional_property_and_then<W: 'static>(self: 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
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeBorrow<T>BorrowMut<T>CloneToUninitInto<U>From<T>TryInto<U>TryFrom<U>AnyToOwnedClone
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.