# HandlerList

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-system/events/struct-handlerlist/

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

```rust
struct HandlerList<F: ?Sized>
```

A list of event handlers that tolerates being modified while it is being
invoked: invocation works on a snapshot, and the snapshot is only copied
when the list actually changes.

A list is one pointer wide. An object with a dozen events, almost all of
which nobody subscribes to, pays that for each of them and nothing else
(desktop-performance.md, section 9.40).

The tokens of every list come from one counter of the process: within a
list, and across lists, a later subscription has a greater token, and a
token is never given out twice. The typed and the untyped form of one
event, which run their handlers in subscription order as the single
event of the original, need nothing more than that.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/events/handler_list.rs#L19)

## Members

- [`new`](#function-new)
- [`is_empty`](#function-is_empty)
- [`len`](#function-len)
- [`add`](#function-add)
- [`remove`](#function-remove)
- [`snapshot`](#function-snapshot)

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

### new

```rust
const fn new() -> Self
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/events/handler_list.rs#L64)

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

### is_empty

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/events/handler_list.rs#L80)

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

### len

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



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/events/handler_list.rs#L84)

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

### add

```rust
fn add(self: &Self, handler: Rc<F>) -> u64
```

Adds a handler and returns a token that removes it again.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/events/handler_list.rs#L89)

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

### remove

```rust
fn remove(self: &Self, token: u64) -> bool
```

Removes the handler registered under `token`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/events/handler_list.rs#L99)

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

### snapshot

```rust
fn snapshot(self: &Self) -> HandlerSnapshot<F>
```

Returns the current handlers; later modifications do not affect it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/events/handler_list.rs#L112)

## Trait implementations

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

## Availability

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