Skip to main content

DesktopAppBuilder

Struct DesktopAppBuilder 

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

Builder for Rust-first WebUI desktop hosts.

Source and bundle inputs share registration and window configuration. No startup rendering occurs until Self::build, so route providers and Rust state participate in the first render, not only subsequent requests.

Implementations§

Source§

impl DesktopAppBuilder

Source

pub fn window(self, window: WindowOptions) -> Self

Set the window options used by both rendering and the native frame.

Source

pub fn shell(self, shell: DesktopShellConfig) -> Self

Set native shell configuration, overriding any bundled defaults.

Source

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

Set the stable application identity used by the native frame.

Source

pub fn max_asset_bytes(self, max_asset_bytes: u64) -> Self

Set the maximum asset bytes buffered in one protocol response.

Source

pub fn state<T: Serialize>(self, state: &T) -> Result<Self>

Set startup state from any serializable Rust value.

§Errors

Returns DesktopError if state serialization fails.

Source

pub fn state_value(self, state: Value) -> Self

Set startup state from an existing JSON value.

Source

pub fn token_css(self, token_css: HashMap<String, String>) -> Self

Set pre-resolved design token CSS.

Source

pub fn route<F>(self, pattern: impl AsRef<str>, handler: F) -> Result<Self>
where F: Fn(RouteContext<'_>) -> Result<Value> + Send + Sync + 'static,

Register a Rust route state provider.

Patterns support literal segments and :param captures, e.g. /contacts/:id.

§Errors

Returns DesktopError if the pattern is invalid.

Source

pub fn api_route<F>(self, pattern: impl AsRef<str>, handler: F) -> Result<Self>
where F: Fn(ApiContext<'_>) -> Result<DesktopProtocolResponse> + Send + Sync + 'static,

Register a Rust custom-protocol API handler.

Patterns support literal segments and :param captures, e.g. /api/contacts/:id.

§Errors

Returns DesktopError if the pattern is invalid.

Source

pub fn build(self) -> Result<DesktopFrame>

Render startup content and construct the owning desktop frame.

§Errors

Returns DesktopError if source compilation, bundle loading, a route provider, or startup rendering fails.

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.