pub trait Renderer {
Show 25 methods
// Required methods
fn init(&mut self) -> Result<()>;
fn create_window(&mut self, config: &WindowConfig) -> Result<WindowHandle>;
fn load_url(&self, window: WindowHandle, url: &str) -> Result<()>;
fn load_html(&self, window: WindowHandle, html: &str) -> Result<()>;
fn eval_script(&self, window: WindowHandle, script: &str) -> Result<()>;
fn set_ipc_handler(&mut self, handler: Box<dyn IpcHandler>);
fn send_to_frontend(
&self,
window: WindowHandle,
message: &str,
) -> Result<()>;
fn set_title(&self, window: WindowHandle, title: &str) -> Result<()>;
fn set_size(
&self,
window: WindowHandle,
width: u32,
height: u32,
) -> Result<()>;
fn set_resizable(&self, window: WindowHandle, resizable: bool) -> Result<()>;
fn set_visible(&self, window: WindowHandle, visible: bool) -> Result<()>;
fn close_window(&mut self, window: WindowHandle) -> Result<()>;
fn minimize_window(&self, window: WindowHandle) -> Result<()>;
fn maximize_window(&self, window: WindowHandle) -> Result<()>;
fn is_maximized(&self, window: WindowHandle) -> Result<bool>;
fn set_fullscreen(
&self,
window: WindowHandle,
fullscreen: bool,
) -> Result<()>;
fn is_fullscreen(&self, window: WindowHandle) -> Result<bool>;
fn start_drag(&self, window: WindowHandle) -> Result<()>;
fn start_resize(&self, window: WindowHandle, edge: ResizeEdge) -> Result<()>;
fn set_decorations(
&self,
window: WindowHandle,
decorations: bool,
) -> Result<()>;
fn set_always_on_top(
&self,
window: WindowHandle,
always: bool,
) -> Result<()>;
fn run(self: Box<Self>) -> Result<()>;
fn kind(&self) -> RendererKind;
// Provided methods
fn load_html_with_base_url(
&self,
window: WindowHandle,
html: &str,
base_url: &str,
) -> Result<()> { ... }
fn set_click_through(
&self,
_window: WindowHandle,
_enabled: bool,
) -> Result<()> { ... }
}Expand description
Core trait that both WebView and Chrome backends must implement.
This provides a unified API for creating windows, loading content, executing JavaScript, and handling IPC regardless of the underlying rendering engine.
Required Methods§
Sourcefn create_window(&mut self, config: &WindowConfig) -> Result<WindowHandle>
fn create_window(&mut self, config: &WindowConfig) -> Result<WindowHandle>
Create a new window with the given configuration.
Sourcefn load_url(&self, window: WindowHandle, url: &str) -> Result<()>
fn load_url(&self, window: WindowHandle, url: &str) -> Result<()>
Load a URL in the specified window.
Sourcefn load_html(&self, window: WindowHandle, html: &str) -> Result<()>
fn load_html(&self, window: WindowHandle, html: &str) -> Result<()>
Load HTML content directly.
Sourcefn eval_script(&self, window: WindowHandle, script: &str) -> Result<()>
fn eval_script(&self, window: WindowHandle, script: &str) -> Result<()>
Execute JavaScript in the specified window.
Sourcefn set_ipc_handler(&mut self, handler: Box<dyn IpcHandler>)
fn set_ipc_handler(&mut self, handler: Box<dyn IpcHandler>)
Set the IPC handler for messages from the frontend.
Sourcefn send_to_frontend(&self, window: WindowHandle, message: &str) -> Result<()>
fn send_to_frontend(&self, window: WindowHandle, message: &str) -> Result<()>
Send a message to the frontend JavaScript.
Sourcefn set_size(&self, window: WindowHandle, width: u32, height: u32) -> Result<()>
fn set_size(&self, window: WindowHandle, width: u32, height: u32) -> Result<()>
Set the window size.
Sourcefn set_resizable(&self, window: WindowHandle, resizable: bool) -> Result<()>
fn set_resizable(&self, window: WindowHandle, resizable: bool) -> Result<()>
Set whether the window is resizable.
Sourcefn set_visible(&self, window: WindowHandle, visible: bool) -> Result<()>
fn set_visible(&self, window: WindowHandle, visible: bool) -> Result<()>
Show or hide the window.
Sourcefn close_window(&mut self, window: WindowHandle) -> Result<()>
fn close_window(&mut self, window: WindowHandle) -> Result<()>
Close a window.
Sourcefn minimize_window(&self, window: WindowHandle) -> Result<()>
fn minimize_window(&self, window: WindowHandle) -> Result<()>
Minimize the window.
Sourcefn maximize_window(&self, window: WindowHandle) -> Result<()>
fn maximize_window(&self, window: WindowHandle) -> Result<()>
Toggle maximize/restore.
Sourcefn is_maximized(&self, window: WindowHandle) -> Result<bool>
fn is_maximized(&self, window: WindowHandle) -> Result<bool>
Check whether the window is currently maximized.
Sourcefn set_fullscreen(&self, window: WindowHandle, fullscreen: bool) -> Result<()>
fn set_fullscreen(&self, window: WindowHandle, fullscreen: bool) -> Result<()>
Toggle fullscreen mode.
Sourcefn is_fullscreen(&self, window: WindowHandle) -> Result<bool>
fn is_fullscreen(&self, window: WindowHandle) -> Result<bool>
Check whether the window is currently fullscreen.
Sourcefn start_drag(&self, window: WindowHandle) -> Result<()>
fn start_drag(&self, window: WindowHandle) -> Result<()>
Begin an interactive window drag.
Call this from a mousedown handler on a custom title bar element
to allow the user to drag the window from any region.
Sourcefn start_resize(&self, window: WindowHandle, edge: ResizeEdge) -> Result<()>
fn start_resize(&self, window: WindowHandle, edge: ResizeEdge) -> Result<()>
Begin an interactive window resize.
edge specifies which edge/corner to resize from.
Sourcefn set_decorations(&self, window: WindowHandle, decorations: bool) -> Result<()>
fn set_decorations(&self, window: WindowHandle, decorations: bool) -> Result<()>
Set whether the window has OS decorations (title bar + borders).
Sourcefn set_always_on_top(&self, window: WindowHandle, always: bool) -> Result<()>
fn set_always_on_top(&self, window: WindowHandle, always: bool) -> Result<()>
Set the window’s always-on-top state.
Sourcefn run(self: Box<Self>) -> Result<()>
fn run(self: Box<Self>) -> Result<()>
Run the main event loop. This blocks until the application exits.
Sourcefn kind(&self) -> RendererKind
fn kind(&self) -> RendererKind
Get the renderer kind.
Provided Methods§
Sourcefn load_html_with_base_url(
&self,
window: WindowHandle,
html: &str,
base_url: &str,
) -> Result<()>
fn load_html_with_base_url( &self, window: WindowHandle, html: &str, base_url: &str, ) -> Result<()>
Load HTML content with a document base URL for relative assets.
WebView backends commonly implement load_html with an in-memory
document (NavigateToString on WebView2). Such documents do not have
a useful filesystem base, so relative Vite assets like
./assets/index.js fail to load. This helper injects a <base> tag
before delegating to the backend and keeps local-first renderers
portable across WebView2, WKWebView, and WebKitGTK.
Sourcefn set_click_through(&self, _window: WindowHandle, _enabled: bool) -> Result<()>
fn set_click_through(&self, _window: WindowHandle, _enabled: bool) -> Result<()>
Enable or disable click-through: when enabled, pointer events fall through the window to whatever is behind it (used by wallpaper and click-through overlays). Applied at window creation by default; this method allows toggling it at runtime where the platform supports it.
Default implementation is a no-op; backends override it to call the platform-specific window API.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".