Crate iced_webview

Source
Expand description

Iced_webview is a library to embed Web views in iced applications. It is a renderer agnostic webview library for Iced.

Note: Currently this library only supports Ultralight/Webkit, but more rendering engines are planned to be supported. Ultralight has its own license that should be reviewed before deciding if it works for you

Has two separate widgets: Basic, and Advanced. The basic widget is very simple to implement and requires no knowledge of the widget. You can use simple abstractions like CloseCurrent, and ChangeView. Whereas with the Advanced widget, you have callbacks when a view is done being created, and you need to keep track of the ViewId for view calls

#Basic usage should look familiar to iced users:

You’ll need to create a Message for Webview:

enum Message {
   WebView(iced_webview::Action),
   Update
}

Create a new struct to store webview state

struct State {
   webview: iced_webview::WebView<iced_webview::Ultralight, Message>,
}

###Then you should be able to call the usual view/update methods:

fn update(state: &mut State, message: Message) -> iced::Task<Message> {
    match message {
        Message::WebView(msg) => state.webview.update(msg),
        Message::Update => state.webview.update(iced_webview::Action::Update),
    }
}
fn view(state: &mut State, message: Message) -> iced::Element<Message> {
   state.webview.view().map(Message::WebView).into()
}

The subscription provides periodic updates so that all the backend rendering is done frequently enough

use iced::time;
fn subscription(state: &mut State) -> iced::Subscription<Message> {
    time::every(std::time::Duration::from_millis(10))
        .map(|_| iced_webview::Action::Update)
        .map(Message::WebView)
}

Examples can be found in the iced_webview repo

Re-exports§

pub use engines::Engine;
pub use engines::PageType;
pub use engines::PixelFormat;
pub use engines::ViewId;

Modules§

advanced
Advanced is a more complex interface than basic and assumes the user stores all the view ids themselves. This gives the user more freedom by allowing them to view multiple views at the same time, but removes actions like close current
basic
Basic allows users to have simple interfaces like close current and allows users to index views by ints like 0, 1 , or 2
engines
Engine Trait and Engine implementations

Structs§

ImageInfo
Image details for passing the view around
WebView
The Basic WebView widget that creates and shows webview(s)

Enums§

Action
Handles Actions for Basic webview