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
impl Builder
pub fn new() -> Self
Sourcepub fn data_dir(self, directory: impl Into<PathBuf>) -> Self
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.
Sourcepub fn storage_encrypted(self, encrypted: bool) -> Self
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.
Sourcepub fn prepare_data_dir<F>(self, prepare: F) -> Self
pub fn prepare_data_dir<F>(self, prepare: F) -> Self
Prepares or migrates the profile after single-instance handling, before any storage or VM initialization. An error or panic stops startup.
Sourcepub fn desktop_launch(self, enabled: bool) -> Self
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).
Sourcepub fn setup<F>(self, setup: F) -> Self
pub fn setup<F>(self, setup: F) -> Self
Runs once on the Skathi thread after storage install, before any app JS or window. An error or panic prevents startup. Keep it short.
Sourcepub fn payload_file(self, path: impl Into<PathBuf>) -> Self
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.
Sourcepub fn payload_bytes(self, bytes: impl Into<Vec<u8>>) -> Self
pub fn payload_bytes(self, bytes: impl Into<Vec<u8>>) -> Self
Owned .skpk bytes. Prefer Self::payload_static for include_bytes!.
Sourcepub fn payload_static(self, bytes: &'static [u8]) -> Self
pub fn payload_static(self, bytes: &'static [u8]) -> Self
A static .skpk, borrowed without copying.
Sourcepub fn args<I, S>(self, args: I) -> Self
pub fn args<I, S>(self, args: I) -> Self
appLaunch.argv after the exe; none of it is read as a host flag.
Sourcepub fn module(self, name: impl Into<String>, exports: impl IntoModule) -> Self
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.
Sourcepub fn task_executor<F>(self, executor: F) -> Self
pub fn task_executor<F>(self, executor: F) -> Self
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.
Sourcepub fn function<F>(self, name: impl Into<String>, handler: F) -> Self
👎Deprecated since 0.4.0: use native modules: Builder::module and import { … } from "native:<name>"
pub fn function<F>(self, name: impl Into<String>, handler: F) -> Self
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.
Sourcepub fn visible(self, visible: bool) -> Self
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.
Sourcepub fn activate(self, on: bool) -> Self
pub fn activate(self, on: bool) -> Self
Whether the app’s window takes the foreground when it opens (default true).
Sourcepub fn inspector_exe(self, path: impl Into<PathBuf>) -> Self
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.
Sourcepub fn desktop_id(self, id: impl Into<String>) -> Self
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.
Sourcepub fn exact_frame_feedback(self, on: bool) -> Self
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.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Builder
impl !Sync for Builder
impl !UnwindSafe for Builder
impl Forget for Builder
impl Freeze for Builder
impl Move for Builder
impl Send for Builder
impl Unpin for Builder
impl UnsafeUnpin for Builder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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