# PropertyPath

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-system/component_model/struct-propertypath/

**struct** · [`ferroui-system`](/docs/0.5.0/api/ferroui-system/) · v0.5.0

```rust
struct PropertyPath<S, V>
```

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

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/component_model/property_path.rs#L27)

## Members

- [`property`](#function-property)
- [`optional_property`](#function-optional_property)
- [`optional_property_and_then`](#function-optional_property_and_then)
- [`object_property`](#function-object_property)
- [`owned_property`](#function-owned_property)
- [`value`](#function-value)
- [`steps`](#function-steps)
- [`names`](#function-names)
- [`path`](#function-path)
- [`get`](#function-get)
- [`getter`](#function-getter)
- [`observe`](#function-observe)
- [`then`](#function-then)
- [`then_property`](#function-then_property)
- [`then_optional_property`](#function-then_optional_property)
- [`then_optional_property_and_then`](#function-then_optional_property_and_then)

<a id="function-property"></a>

### property

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/component_model/property_path.rs#L168)

<a id="function-optional_property"></a>

### optional_property

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/component_model/property_path.rs#L195)

<a id="function-optional_property_and_then"></a>

### optional_property_and_then

```rust
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 `Option`s.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/component_model/property_path.rs#L229)

<a id="function-object_property"></a>

### object_property

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/component_model/property_path.rs#L266)

<a id="function-owned_property"></a>

### owned_property

```rust
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 `Rc`s of a type that raises `PropertyChanged`
(handles of the objects of a user interface) writes the steps of its properties.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/component_model/property_path.rs#L284)

<a id="function-value"></a>

### value

```rust
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](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/component_model/property_path.rs#L309)

<a id="function-steps"></a>

### steps

```rust
fn steps(self: &Self) -> &[PathStep]
```

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/component_model/property_path.rs#L328)

<a id="function-names"></a>

### names

```rust
fn names(self: &Self) -> &[String]
```

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/component_model/property_path.rs#L333)

<a id="function-path"></a>

### path

```rust
fn path(self: &Self) -> String
```

The path as text, `Address.Street`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/component_model/property_path.rs#L338)

<a id="function-get"></a>

### get

```rust
fn get(self: &Self, source: &S) -> V
```

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

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/component_model/property_path.rs#L343)

<a id="function-getter"></a>

### getter

```rust
fn getter(self: &Self) -> Rc<dyn Fn(&S) -> V>
```

The getter of the path.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/component_model/property_path.rs#L348)

<a id="function-observe"></a>

### observe

```rust
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.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/component_model/property_path.rs#L354)

<a id="function-then"></a>

### then

```rust
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.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/component_model/property_path.rs#L360)

<a id="function-then_property"></a>

### then_property

```rust
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.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/component_model/property_path.rs#L402)

<a id="function-then_optional_property"></a>

### then_optional_property

```rust
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.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/component_model/property_path.rs#L410)

<a id="function-then_optional_property_and_then"></a>

### then_optional_property_and_then

```rust
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())`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/component_model/property_path.rs#L419)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `Clone`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
