# Subscription

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

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

```rust
struct Subscription
```

A subscription or resource released when the guard is dropped.

The guard holds the [`IDisposable`](/docs/0.5.0/api/ferroui-system/trait-idisposable/) handle an API returned and disposes it
once: when it is dropped, or earlier with `dispose`. A
subscription meant to last as long as its source is kept with
`detach`, which gives the handle back without disposing it
(dropping an `Rc<dyn IDisposable>` keeps the subscription alive).

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

## Members

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

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

### new

```rust
fn new(handle: Rc<dyn IDisposable>) -> Self
```

The guard of `handle`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/subscription.rs#L19)

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

### dispose

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

Releases the subscription now, the same as dropping the guard.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/subscription.rs#L24)

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

### detach

```rust
fn detach(self: Self) -> Rc<dyn IDisposable>
```

Keeps the subscription for the life of its source and returns its
handle, which can still dispose it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/subscription.rs#L30)

## Trait implementations

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

## Availability

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