Skip to main content

Builder

Struct Builder 

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

Configures and starts an embedded Skathi.

let ui = sk_app::embed::Builder::new()
    .payload_file("apps/hello/dist/release/.sk/app.skpk")
    .module("db", |m: &mut sk_app::embed::Module| {
        m.task("query", |sql: String| -> Result<Vec<String>, String> { Ok(vec![sql]) });
        m.event::<bool>("online");
    })
    .spawn()?;
ui.emit_to("db", "online", &true)?;
let exit = ui.wait();

Implementations§

Source§

impl Builder

Source

pub fn new() -> Self

Source

pub fn data_dir(self, directory: impl Into<PathBuf>) -> Self

Sets the persistent profile root, before storage and cookies load. HTTP and bytecode caches live in its cache/http and cache/jsc. SK_DATA_DIR overrides it. Must be absolute.

Source

pub fn storage_encrypted(self, encrypted: bool) -> Self

Sets storage encryption before any cookie, database or app code runs. true requires an OS provider and seals existing plaintext localStorage before boot.

Source

pub fn prepare_data_dir<F>(self, prepare: F) -> Self
where F: FnOnce(&Path) -> Result<(), String> + Send + 'static,

Prepares or migrates the profile after single-instance handling, before any storage or VM initialization. An error or panic stops startup.

Source

pub fn desktop_launch(self, enabled: bool) -> Self

Lets this binary own the payload’s single-instance and protocol policy, using the real command line (a deep link’s raw URL included). A forwarded launch returns Error::LaunchExit(0).

Source

pub fn setup<F>(self, setup: F) -> Self
where F: FnOnce(&HostContext<'_>) -> Result<(), String> + Send + 'static,

Runs once on the Skathi thread after storage install, before any app JS or window. An error or panic prevents startup. Keep it short.

Source

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

The .skpk file sk build writes (--features prod only), mapped read-only for the app’s lifetime: replace it atomically, never modify it in place.

Source

pub fn payload_bytes(self, bytes: impl Into<Vec<u8>>) -> Self

Owned .skpk bytes. Prefer Self::payload_static for include_bytes!.

Source

pub fn payload_static(self, bytes: &'static [u8]) -> Self

A static .skpk, borrowed without copying.

Source

pub fn args<I, S>(self, args: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

appLaunch.argv after the exe; none of it is read as a host flag.

Source

pub fn module(self, name: impl Into<String>, exports: impl IntoModule) -> Self

A native module the app imports as native:<name>: a value of a #[skathi::module] type, or a closure |m: &mut Module| … that registers its functions, tasks and events.

Source

pub fn task_executor<F>(self, executor: F) -> Self
where F: Fn(Job) + Send + Sync + 'static,

Runs module tasks on the embedder’s own executor (a tokio or rayon pool) instead of Skathi’s four worker threads. A job it drops unrun rejects its promise.

Source

pub fn function<F>(self, name: impl Into<String>, handler: F) -> Self
where F: Fn(Call) + Send + Sync + 'static,

👎Deprecated since 0.4.0:

use native modules: Builder::module and import { … } from "native:<name>"

A function the app calls as appHost.call(name, ...args); the handler gets the arguments as a JSON array and answers through the Call.

Source

pub fn visible(self, visible: bool) -> Self

Whether the primary window is shown at startup (default true). Hidden apps still boot JS and pump background work, and do not activate or raise an already running instance.

Source

pub fn activate(self, on: bool) -> Self

Whether the app’s window takes the foreground when it opens (default true).

Source

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

A sk-app.exe of this Skathi version, started as the inspector on F12 and appDevtools.open(). Without it they say why nothing opened; the devtools protocol works either way.

Source

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

The app’s desktop entry id on Linux (gl.example.App): the Wayland app id and X11 class of its windows, which the desktop matches to the entry’s icon and dock slot. Ignored elsewhere.

Source

pub fn exact_frame_feedback(self, on: bool) -> Self

On Windows, reports frames once the compositor has finished each refresh (default false): every FrameEvent::Presented is Exact and no frame misses its refresh to another application’s update, but every window present reaches the screen one refresh later.

Source

pub fn spawn(self) -> Result<Handle, Error>

Starts Skathi on a thread of its own and returns at once; events emitted before the app is ready wait for it. On macOS this returns Error::MainThreadRequired: use Self::run_on_main_thread instead.

Trait Implementations§

Source§

impl Default for Builder

Source§

fn default() -> Self

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

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

Source§

fn downcast(&self) -> &T

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

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

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WasmNotSend for T
where T: Send,

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