# Struct `kurogane::Responder`

```rust
pub struct Responder<T> { /* private fields */ }
```

The answer to one async request.

Resolving it takes it; a request is answered once. A responder dropped
without [`resolve`](https://kurogane-rs.org/docs/api/ipc/responder.md#method.resolve) rejects its promise. Every pending
request settles.

[Responder::resolve]: https://kurogane-rs.org/docs/api/ipc/responder.md#method.resolve

## Methods

### `new`

```rust
pub fn new(callback: Box<dyn FnOnce(Result<T, IpcError>) + Send>) -> Self
```

Creates a responder that hands its result to `callback`. The runtime
gives one to an async handler; a test of the handler can do the same.

### `is_cancelled`

```rust
pub fn is_cancelled(&self) -> bool
```

Whether this responder has been cancelled.
Typically by an incoming RPC_CANCEL from the renderer.

### `resolve`

```rust
pub fn resolve(self, result: Result<T, IpcError>)
```

Answers the request, unless it was cancelled meanwhile.

### `map`

```rust
pub fn map<U, F>(self, f: F) -> Responder<U>
where
    U: 'static,
    F: FnOnce(U) -> Result<T, IpcError> + Send + 'static,
```

Transform the resolved value type.

The returned responder chains through `f` before calling the original
callback. Useful for wrapping a typed `Responder<Res>` into a
`Responder<Vec<u8>>` at the serialisation boundary.

The mapped responder shares the cancellation flag with the source.
Cancelling the source or the mapped responder cancels both.

## Trait implementations

- `impl<T> Drop for Responder<T>`

Source: https://github.com/0x48piraj/kurogane/blob/584c586118ee53cc04604007ee038557bd859092/kurogane/src/ipc/responder.rs#L14
