# Struct `kurogane::StreamResponder`

```rust
pub struct StreamResponder { /* private fields */ }
```

Responder for sending data from a browser-side stream handler to the renderer.

A responder the runtime hands a handler is bound to its stream and its
document. Once any clone has sent the stream's end or error, or the
stream is closed or its document has ended, every send returns `Err`.

## Methods

### `send_data`

```rust
pub fn send_data(&self, data: &[u8]) -> Result<(), IpcError>
```

Sends a data chunk to the page's `onData`.

#### Errors

Returns `Err` and sends nothing when the stream has ended or failed,
or the document that opened it has gone (its frame navigated or
closed).

### `end`

```rust
pub fn end(&self, result: &str) -> Result<(), IpcError>
```

Ends the stream. The page's `onEnd` receives `result`.

The first `end` or `error` sent, from any clone, closes the stream.

#### Errors

As [`send_data`](https://kurogane-rs.org/docs/api/ipc/streamresponder.md#method.send_data); the error's message is `stream
closed` once the stream has ended or failed.

[Self::send_data]: https://kurogane-rs.org/docs/api/ipc/streamresponder.md#method.send_data

### `error`

```rust
pub fn error(&self, error: impl Into<IpcError>) -> Result<(), IpcError>
```

Fails the stream. The page's `onError` receives the error's message.
A string is an [`IpcError::new`].

Closes the stream, as [`end`](https://kurogane-rs.org/docs/api/ipc/streamresponder.md#method.end) does.

#### Errors

As [`end`](https://kurogane-rs.org/docs/api/ipc/streamresponder.md#method.end).

[Self::end]: https://kurogane-rs.org/docs/api/ipc/streamresponder.md#method.end
[`IpcError::new`]: https://kurogane-rs.org/docs/api/ipc/ipcerror.md#method.new

## Trait implementations

- `impl Clone for StreamResponder`

Source: https://github.com/0x48piraj/kurogane/blob/584c586118ee53cc04604007ee038557bd859092/kurogane/src/ipc/stream/mod.rs#L28
