# Receiver

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/

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

```rust
struct Receiver<T>
```

The end of a [`channel`](/docs/0.5.0/api/ferroui-system/task/oneshot/function-channel/) that waits for the value: a future of it, or of [`Canceled`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-canceled/) when the
sender was dropped without sending.

The value is taken once: after the receiver gave it (as the output of a poll, or from
`try_recv`), the channel is empty for good, and the receiver gives
[`Canceled`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-canceled/). Dropping the receiver makes `Sender::send` give the value back.

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

## Members

- [`try_recv`](#function-try_recv)
- [`is_finished`](#function-is_finished)
- [`blocking_recv`](#function-blocking_recv)
- [`recv_timeout`](#function-recv_timeout)
- [`shared`](#function-shared)
- [`flatten`](#function-flatten)

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

### try_recv

```rust
fn try_recv(self: &mut Self) -> Result<Option<T>, Canceled>
```

The value when it was sent (`Ok(Some)`), `Ok(None)` while it was not, and `Canceled` when
the sender was dropped without sending, or the value was taken already.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/task/oneshot.rs#L198)

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

### is_finished

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

Whether the channel has completed: the value was sent or the sender is gone, so that a
poll is ready.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/task/oneshot.rs#L209)

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

### blocking_recv

```rust
fn blocking_recv(self: Self) -> Result<T, Canceled>
```

Blocks the thread until the value is sent, or the sender is dropped.

Never returns when the value is to be sent by work of this same thread.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/task/oneshot.rs#L216)

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

### recv_timeout

```rust
fn recv_timeout(self: &mut Self, timeout: Duration) -> Result<Option<T>, Canceled>
```

Blocks the thread until the value is sent, the sender is dropped, or `timeout` has passed;
`Ok(None)` is the timeout.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/task/oneshot.rs#L225)

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

### shared

```rust
fn shared(self: Self) -> SharedReceiver<T>
where T: Clone
```

A receiver for several waiters: see `SharedReceiver`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/task/oneshot.rs#L235)

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

### flatten

```rust
fn flatten(self: Self) -> impl Future<Output = Result<T, crate::ObservableError>>
```

A future of the result that the channel carries: what was sent, or the error `Canceled`
when the sender was dropped without sending (`SetCanceled`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.System/task/oneshot.rs#L247)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `IntoFuture`
- `Future`
- `Drop`
- `Debug`
- `From<Receiver<Result<T, Rc<dyn Error>>>>`

## Availability

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