# Handler

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-view/element/struct-handler/

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

```rust
struct Handler
```

A handler of an element. Its closure is in a cell that the attached
trampoline reads, so that a component that runs again with handlers of
the same identities in the same order swaps the closures into the cells
of the attached handlers instead of detaching and attaching them.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.View/element.rs#L159)

## Members

- [`identity`](#struct_field-identity)
- [`attach`](#struct_field-attach)
- [`cell`](#struct_field-cell)
- [`swap`](#struct_field-swap)
- [`attached_again`](#function-attached_again)

<a id="struct_field-identity"></a>

### identity

```rust
identity: usize
```

What it handles: the address of the routed event or of the property;
0 for a handler that is attached again on every run.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.View/element.rs#L162)

<a id="struct_field-attach"></a>

### attach

```rust
attach: Attach
```

Attaches the trampoline of `cell` to a control.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.View/element.rs#L164)

<a id="struct_field-cell"></a>

### cell

```rust
cell: std::rc::Rc<dyn Any>
```

The closure: a `RefCell<Rc<dyn Fn(..)>>` of the type of the handler.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.View/element.rs#L166)

<a id="struct_field-swap"></a>

### swap

```rust
swap: fn(&dyn Any, &dyn Any) -> ()
```

Puts the closure of the second cell into the first (cells of this
handler's type).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.View/element.rs#L169)

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

### attached_again

```rust
fn attached_again(attach: Attach) -> Self
```

A handler that is attached again on every run (no cell to swap).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.View/element.rs#L174)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`IntoValue<T>`](/docs/0.5.0/api/ferroui-view/builder/trait-intovalue/)
- [`FromValue<T>`](/docs/0.5.0/api/ferroui-view/builder/trait-fromvalue/)
- [`FromValue<Option<T>>`](/docs/0.5.0/api/ferroui-view/builder/trait-fromvalue/)
- [`IntoProp<T, Value>`](/docs/0.5.0/api/ferroui-view/builder/trait-intoprop/)
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`
- `Clone`

## Availability

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