# Trait `kurogane::SchemeHandler`

```rust
pub trait SchemeHandler: Send + Sync {
    fn create(
        &self,
        browser: Option<&mut Browser>,
        frame: Option<&mut Frame>,
        request: Option<&mut Request>,
    ) -> Option<ResourceHandler>;
}
```

Generates a [`ResourceHandler`] for requests on a custom scheme.

Implement this trait and pass the instance to
[`App::register_scheme`](https://kurogane-rs.org/docs/api/app/app.md#method.register_scheme) to expose a custom
scheme to the frontend. The trait method mirrors
[`SchemeHandlerFactory::create`](https://docs.rs/tanso/latest/tanso/bindings/x86_64_pc_windows_msvc/struct.SchemeHandlerFactory.html) minus the
scheme name which is fixed per registration.

CEF calls `create` on the browser-process IO thread, which also carries
every IPC message and must not block. Decide there what to answer. Slow
work, such as reading a file, belongs in the returned handler's `open` and
`read`, which CEF calls on a worker thread that may block.

A panic in `create` fails the request, as returning `None` does (with
Rust's default `panic = "unwind"`). A [`ResourceHandler`] you implement
yourself is called by CEF directly. A panic inside it aborts the process.

[`resource_handler_from_bytes`] covers the common static-bytes case.

[`ResourceHandler`]: https://docs.rs/tanso/latest/tanso/bindings/x86_64_pc_windows_msvc/struct.ResourceHandler.html
[tanso::SchemeHandlerFactory]: https://docs.rs/tanso/latest/tanso/bindings/x86_64_pc_windows_msvc/struct.SchemeHandlerFactory.html
[crate::App::register_scheme]: https://kurogane-rs.org/docs/api/app/app.md#method.register_scheme
[`resource_handler_from_bytes`]: https://kurogane-rs.org/docs/api/app/resource_handler_from_bytes.md

## Required methods

### `create`

```rust
fn create(
    &self,
    browser: Option<&mut Browser>,
    frame: Option<&mut Frame>,
    request: Option<&mut Request>,
) -> Option<ResourceHandler>
```

Create a resource handler for `request`, or `None` to fail the request.

Source: https://github.com/0x48piraj/kurogane/blob/584c586118ee53cc04604007ee038557bd859092/kurogane/src/scheme.rs#L115
