Config

Struct Config 

Source
pub struct Config { /* private fields */ }
Expand description

The configuration for the desktop application.

Implementations§

Source§

impl Config

Source

pub fn new() -> Self

Initializes a new WindowBuilder with default values.

Source

pub fn with_resource_directory(self, path: impl Into<PathBuf>) -> Self

set the directory from which assets will be searched in release mode

Source

pub fn with_data_directory(self, path: impl Into<PathBuf>) -> Self

set the directory where data will be stored in release mode.

Note: This must be set when bundling on Windows.

Source

pub fn with_disable_context_menu(self, disable: bool) -> Self

Set whether or not the right-click context menu should be disabled.

Source

pub fn with_disable_drag_drop_handler(self, disable: bool) -> Self

Set whether or not the file drop handler should be disabled. On Windows the drop handler must be disabled for HTML drag and drop APIs to work.

Source

pub fn with_prerendered(self, content: String) -> Self

Set the pre-rendered HTML content

Source

pub fn with_event_loop(self, event_loop: EventLoop<UserWindowEvent>) -> Self

Set the event loop to be used

Source

pub fn with_window(self, window: WindowBuilder) -> Self

Set the configuration for the window.

Source

pub fn with_as_child_window(self) -> Self

Set the window as child

Source

pub fn with_exits_when_last_window_closes(self, exit: bool) -> Self

When the last window is closed, the application will exit.

This is the default behaviour.

If the last window is hidden, the application will not exit.

Source

pub fn with_close_behaviour(self, behaviour: WindowCloseBehaviour) -> Self

Sets the behaviour of the application when the last window is closed.

Source

pub fn with_custom_event_handler( self, f: impl FnMut(&Event<'_, UserWindowEvent>, &EventLoopWindowTarget<UserWindowEvent>) + 'static, ) -> Self

Sets a custom callback to run whenever the event pool receives an event.

Source

pub fn with_custom_protocol<F>(self, name: impl ToString, handler: F) -> Self
where F: Fn(WebViewId<'_>, HttpRequest<Vec<u8>>) -> HttpResponse<Cow<'static, [u8]>> + 'static,

Set a custom protocol

Source

pub fn with_asynchronous_custom_protocol<F>( self, name: impl ToString, handler: F, ) -> Self
where F: Fn(WebViewId<'_>, HttpRequest<Vec<u8>>, RequestAsyncResponder) + 'static,

Set an asynchronous custom protocol

Example Usage

let cfg = Config::new()
    .with_asynchronous_custom_protocol("asset", |_webview_id, request, responder| {
        tokio::spawn(async move {
            responder.respond(
                HTTPResponse::builder()
                    .status(404)
                    .body(Cow::Borrowed("404 - Not Found".as_bytes()))
                    .unwrap()
            );
        });
    });

note a key difference between Dioxus and Wry, the protocol name doesn’t explicitly need to be a String, but needs to implement ToString.

See wry for more details on implementation

Source

pub fn with_icon(self, icon: Icon) -> Self

Set a custom icon for this application

Source

pub fn with_custom_head(self, head: String) -> Self

Inject additional content into the document’s HEAD.

This is useful for loading CSS libraries, JS libraries, etc.

Source

pub fn with_custom_index(self, index: String) -> Self

Use a custom index.html instead of the default Dioxus one.

Make sure your index.html is valid HTML.

Dioxus injects some loader code into the closing body tag. Your document must include a body element!

Source

pub fn with_root_name(self, name: impl Into<String>) -> Self

Set the name of the element that Dioxus will use as the root.

This is akin to calling React.render() on the element with the specified name.

Source

pub fn with_background_color(self, color: (u8, u8, u8, u8)) -> Self

Sets the background color of the WebView. This will be set before the HTML is rendered and can be used to prevent flashing when the page loads. Accepts a color in RGBA format

Source

pub fn with_menu(self, menu: impl Into<Option<Menu>>) -> Self

Sets the menu the window will use. This will override the default menu bar.

Note: Menu will be hidden if with_decorations is set to false and passed into with_window

Source

pub fn with_on_window( self, f: impl FnMut(Arc<Window>, &mut VirtualDom) + 'static, ) -> Self

Allows modifying the window and virtual dom right after they are built, but before the webview is created.

This is important for z-ordering textures in child windows. Note that this callback runs on every window creation, so it’s up to you to

Source

pub fn with_disable_dma_buf_on_wayland(self, disable: bool) -> Self

Set whether or not DMA-BUF usage should be disabled on Wayland.

Defaults to true to avoid issues on some systems. If you want to enable DMA-BUF usage, set this to false. See https://github.com/DioxusLabs/dioxus/issues/4528#issuecomment-3476430611

Source

pub fn with_windows_browser_args(self, additional_args: impl ToString) -> Self

Add additional windows only launch arguments for webview2

Trait Implementations§

Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl LaunchConfig for Config

Auto Trait Implementations§

§

impl Freeze for Config

§

impl !RefUnwindSafe for Config

§

impl !Send for Config

§

impl !Sync for Config

§

impl Unpin for Config

§

impl !UnwindSafe for Config

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> InitializeFromFunction<T> for T

Source§

fn initialize_from_function(f: fn() -> T) -> T

Create an instance of this type from an initialization function
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<Ret> SpawnIfAsync<(), Ret> for Ret

Source§

fn spawn(self) -> Ret

Spawn the value into the dioxus runtime if it is an async block
Source§

impl<T, O> SuperFrom<T> for O
where O: From<T>,

Source§

fn super_from(input: T) -> O

Convert from a type to another type.
Source§

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

Source§

fn super_into(self) -> O

Convert from a type to another type.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,