# RelativeSource

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/data/struct-relativesource/

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

```rust
struct RelativeSource
```

Describes the location of a binding source, relative to the binding
target.

A relative source is a mutable reference object: it is created with
`RelativeSource::empty` or `RelativeSource::new`, configured property
by property (or with the chaining `with_*` forms) and shared as
`Rc<RelativeSource>`. Handles compare by identity. A binding reads it
when it is instantiated on a target.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/relative_source.rs#L37)

## Members

- [`empty`](#function-empty)
- [`new`](#function-new)
- [`ancestor_level`](#function-ancestor_level)
- [`set_ancestor_level`](#function-set_ancestor_level)
- [`with_ancestor_level`](#function-with_ancestor_level)
- [`ancestor_type`](#function-ancestor_type)
- [`set_ancestor_type`](#function-set_ancestor_type)
- [`with_ancestor_type`](#function-with_ancestor_type)
- [`mode`](#function-mode)
- [`set_mode`](#function-set_mode)
- [`with_mode`](#function-with_mode)
- [`tree`](#function-tree)
- [`set_tree`](#function-set_tree)
- [`with_tree`](#function-with_tree)

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

### empty

```rust
fn empty() -> Rc<Self>
```

Creates a relative source in find-ancestor mode (the parameterless
constructor).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/relative_source.rs#L68)

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

### new

```rust
fn new(mode: RelativeSourceMode) -> Rc<Self>
```

Creates a relative source with the given mode.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/relative_source.rs#L73)

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

### ancestor_level

```rust
fn ancestor_level(self: &Self) -> i32
```

The level of ancestor to look for when in find-ancestor mode. Use the
default value of 1 to look for the first ancestor of the specified
type.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/relative_source.rs#L80)

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

### set_ancestor_level

```rust
fn set_ancestor_level(self: &Self, value: i32)
```

Sets the ancestor level. Panics if it is not positive.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/relative_source.rs#L85)

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

### with_ancestor_level

```rust
fn with_ancestor_level(self: Rc<Self>, value: i32) -> Rc<Self>
```

The chaining form of `set_ancestor_level`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/relative_source.rs#L93)

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

### ancestor_type

```rust
fn ancestor_type(self: &Self) -> Option<&'static TypeInfo>
```

The type of ancestor to look for when in
`RelativeSourceMode::FindAncestor` mode.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/relative_source.rs#L100)

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

### set_ancestor_type

```rust
fn set_ancestor_type(self: &Self, value: Option<&'static TypeInfo>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/relative_source.rs#L104)

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

### with_ancestor_type

```rust
fn with_ancestor_type(self: Rc<Self>, value: Option<&'static TypeInfo>) -> Rc<Self>
```

The chaining form of `set_ancestor_type`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/relative_source.rs#L109)

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

### mode

```rust
fn mode(self: &Self) -> RelativeSourceMode
```

A value that describes the type of relative source lookup.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/relative_source.rs#L115)

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

### set_mode

```rust
fn set_mode(self: &Self, value: RelativeSourceMode)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/relative_source.rs#L119)

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

### with_mode

```rust
fn with_mode(self: Rc<Self>, value: RelativeSourceMode) -> Rc<Self>
```

The chaining form of `set_mode`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/relative_source.rs#L124)

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

### tree

```rust
fn tree(self: &Self) -> TreeType
```

The tree in which ancestors are looked up.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/relative_source.rs#L130)

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

### set_tree

```rust
fn set_tree(self: &Self, value: TreeType)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/relative_source.rs#L134)

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

### with_tree

```rust
fn with_tree(self: Rc<Self>, value: TreeType) -> Rc<Self>
```

The chaining form of `set_tree`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/data/relative_source.rs#L139)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ErasedDestructor`
- `IntoEither`
- `Debug`
- `Default`
- `PartialEq`
- [`MarkupTyped`](/docs/0.5.0/api/ferroui-base/metadata/trait-markuptyped/)

## Availability

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