# CancellationDisposable

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-reactive/disposables/struct-cancellationdisposable/

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

```rust
struct CancellationDisposable
```

A disposable that cancels a cancellation token when it is disposed
(`CancellationDisposable`).

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/disposables/cancellation_disposable.rs#L10)

## Members

- [`new`](#function-new)
- [`with_token`](#function-with_token)
- [`with_source`](#function-with_source)
- [`token`](#function-token)

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

### new

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

A disposable over a new cancellation token.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/disposables/cancellation_disposable.rs#L16)

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

### with_token

```rust
fn with_token(token: CancellationToken) -> Rc<Self>
```

A disposable that cancels `token` when it is disposed (`CancellationDisposable(cts)`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/disposables/cancellation_disposable.rs#L21)

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

### with_source

```rust
fn with_source(source: ferroui_system::threading::CancellationTokenSource) -> Rc<Self>
```

A disposable that cancels `source` when it is disposed.

> **Deprecated since 0.5.0.** use `with_token`, with a `CancellationToken::new()` in the place of the source

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/disposables/cancellation_disposable.rs#L28)

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

### token

```rust
fn token(self: &Self) -> CancellationToken
```

The token that disposing cancels (a clone of it).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Reactive/disposables/cancellation_disposable.rs#L33)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- [`IDisposable`](/docs/0.5.0/api/ferroui-base/reactive/use-idisposable/)
- [`ICancelable`](/docs/0.5.0/api/ferroui-reactive/disposables/trait-icancelable/)

## Availability

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