# CancellationGuard

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-system/threading/struct-cancellationguard/

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

```rust
struct CancellationGuard
```

A callback registered with `CancellationToken::register` or
`CancellationToken::register_local`, removed when the guard is dropped (the place of
`CancellationTokenRegistration`).

The shape of `Subscription`: `dispose` removes it now,
`detach` keeps it for the life of the token. A callback that is running when
its guard is dropped finishes (.NET's `Dispose` waits for it).

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/threading/cancellation_token.rs#L323)

## Members

- [`dispose`](#function-dispose)
- [`detach`](#function-detach)

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

### dispose

```rust
fn dispose(self: Self)
```

Removes the callback now, the same as dropping the guard.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/threading/cancellation_token.rs#L331)

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

### detach

```rust
fn detach(self: Self)
```

Keeps the callback for the life of the token.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/threading/cancellation_token.rs#L336)

## Trait implementations

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

## Availability

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