Menu

Trait

SchemeHandler

kurogane::SchemeHandlerSource
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 to expose a custom scheme to the frontend. The trait method mirrors SchemeHandlerFactory::create 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.

Required methods

#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.