pub struct ViewerOptions {
pub content: ViewerContent,
pub window: WindowOptions,
pub behaviour: BehaviourOptions,
pub environment: EnvironmentOptions,
pub dialog: DialogOptions,
pub wait: ViewerWaitMode,
}Expand description
Options for configuring a viewer instance.
This struct provides full control over how the viewer window behaves, what content it displays, and how it interacts with the user.
§Examples
Creating options for different content types:
use html_view::ViewerOptions;
use std::path::PathBuf;
// Inline HTML
let opts1 = ViewerOptions::inline_html("<h1>Hello</h1>");
// Local file
let opts2 = ViewerOptions::local_file(PathBuf::from("index.html"));
// Application directory
let opts3 = ViewerOptions::app_dir(PathBuf::from("./dist"));Customizing options:
use html_view::ViewerOptions;
let mut opts = ViewerOptions::inline_html("<h1>Custom</h1>");
opts.window.width = Some(800);
opts.window.height = Some(600);
opts.window.title = Some("My App".to_string());
opts.behaviour.enable_devtools = true;
opts.environment.timeout_seconds = Some(30);Fields§
§content: ViewerContentThe content to display.
See ViewerContent for all supported content types.
window: WindowOptionsWindow configuration.
Controls size, position, decorations, and visual appearance.
behaviour: BehaviourOptionsBehaviour and security options.
Controls navigation, remote content, devtools, and notifications.
environment: EnvironmentOptionsEnvironment options.
Controls working directory and timeout behavior.
dialog: DialogOptionsDialog configuration.
Controls whether file and message dialogs are allowed.
wait: ViewerWaitModeWhether to wait for the viewer to close.
In ViewerWaitMode::Blocking mode, the call blocks until the window closes.
In ViewerWaitMode::NonBlocking mode, returns immediately with a handle.
Implementations§
Source§impl ViewerOptions
impl ViewerOptions
Sourcepub fn inline_html<S: Into<String>>(html: S) -> Self
pub fn inline_html<S: Into<String>>(html: S) -> Self
Create options for displaying inline HTML with default settings.
This uses secure defaults:
- Window size: 1024x768
- Resizable: true
- External navigation: disabled
- Devtools: disabled
- Remote content: disabled
- Wait mode: Blocking
§Example
use html_view::ViewerOptions;
let options = ViewerOptions::inline_html("<h1>Hello!</h1>");Sourcepub fn local_file(path: PathBuf) -> Self
pub fn local_file(path: PathBuf) -> Self
Create options for displaying a local HTML file.
§Example
use html_view::ViewerOptions;
use std::path::PathBuf;
let options = ViewerOptions::local_file(PathBuf::from("index.html"));Sourcepub fn app_dir(root: PathBuf) -> Self
pub fn app_dir(root: PathBuf) -> Self
Create options for displaying an HTML application directory.
§Example
use html_view::ViewerOptions;
use std::path::PathBuf;
let options = ViewerOptions::app_dir(PathBuf::from("./dist"));Sourcepub fn remote_url(url: Url) -> Self
pub fn remote_url(url: Url) -> Self
Create options for displaying a remote URL.
Note: This automatically enables allow_remote_content in the behaviour options.
§Example
use html_view::ViewerOptions;
use url::Url;
let url = Url::parse("https://example.com").unwrap();
let options = ViewerOptions::remote_url(url);Trait Implementations§
Source§impl Clone for ViewerOptions
impl Clone for ViewerOptions
Source§fn clone(&self) -> ViewerOptions
fn clone(&self) -> ViewerOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more