# Node

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-dynamic-data/cache/struct-node/

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

```rust
struct Node<T, K>
```

A node of a tree (`Node<TObject, TKey>`): an item, its key, its parent and its children, as
`TransformToTree` builds them. Nodes are held in `Rc`.

Deviation (DEVIATIONS.md, DynamicData): a node holds its parent weakly, so that a parent and
its children (which it holds) do not keep each other alive; the parent of a node is the node
of the tree that is its parent, which the tree keeps.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/node.rs#L16)

## Members

- [`new`](#function-new)
- [`with_parent`](#function-with_parent)
- [`children`](#function-children)
- [`depth`](#function-depth)
- [`is_root`](#function-is_root)
- [`item`](#function-item)
- [`key`](#function-key)
- [`parent`](#function-parent)

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

### new

```rust
fn new(item: T, key: K) -> Rc<Self>
```

A node without a parent (`Node(TObject, TKey)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/node.rs#L27)

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

### with_parent

```rust
fn with_parent(item: T, key: K, parent: Option<&Rc<Node<T, K>>>) -> Rc<Self>
```

A node of `parent` (`Node(TObject, TKey, in Optional<Node<TObject, TKey>>)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/node.rs#L32)

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

### children

```rust
fn children(self: &Self) -> &ObservableCache<Rc<Node<T, K>>, K>
```

The child nodes (`Children`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/node.rs#L39)

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

### depth

```rust
fn depth(self: &Self) -> usize
```

The number of ancestors of the node (`Depth`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/node.rs#L44)

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

### is_root

```rust
fn is_root(self: &Self) -> bool
```

Whether the node has no parent (`IsRoot`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/node.rs#L55)

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

### item

```rust
fn item(self: &Self) -> &T
```

The item (`Item`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/node.rs#L60)

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

### key

```rust
fn key(self: &Self) -> &K
```

The key of the item (`Key`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/node.rs#L65)

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

### parent

```rust
fn parent(self: &Self) -> Option<Rc<Node<T, K>>>
```

The parent node (`Parent`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.DynamicData/cache/node.rs#L70)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToString`
- `Equivalent<K>`
- [`IDisposable`](/docs/0.5.0/api/ferroui-base/reactive/use-idisposable/)
- `PartialEq`
- `Eq`
- `Hash`
- `Display`
- `Debug`

## Availability

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