pub struct Bootloader { /* private fields */ }Expand description
A thin bootloader over LoadSession for a single-library product binary.
// `my-server ARGS...` boots exactly like `sim serve ARGS...`, dispatching the
// library's `cli/main/serve` entrypoint. No Cx::new in the binary.
let code = Bootloader::standard()
.host_verb("serve", "lib/my-server", || Box::new(MyServeLib::new()))
.run(std::iter::once("serve".into()).chain(std::env::args_os().skip(1)))?;
std::process::exit(code);Implementations§
Source§impl Bootloader
impl Bootloader
Sourcepub fn standard() -> Self
pub fn standard() -> Self
The standard boot session: the in-process host loader only, matching the
default sim binary. Add libraries with Bootloader::host_verb.
Sourcepub fn host_verb<F>(self, verb: &str, name: &str, factory: F) -> Self
pub fn host_verb<F>(self, verb: &str, name: &str, factory: F) -> Self
Registers a statically-linked library under name and makes it the default
source for verb, so a bare <verb> ARGS... dispatches to the library’s
cli/main/<verb> entrypoint with no explicit --load.
The library must be a LibTarget::HostRegistered
lib that exports a cli/main/<verb> function (see
crate::cli_main_entrypoint_symbol).
Sourcepub fn host_lib<F>(self, name: &str, factory: F) -> Self
pub fn host_lib<F>(self, name: &str, factory: F) -> Self
Registers a statically-linked library under name WITHOUT binding it to a
verb – for a supporting library the served verb needs, most commonly the boot
codec (register it under codec/<name> and pass --codec <name> so the boot
resolves the host codec instead of the default).
Sourcepub fn with_capability(self, capability: CapabilityName) -> Self
pub fn with_capability(self, capability: CapabilityName) -> Self
Grants a capability the served library requires (for example a transport or tool-call capability).
Sourcepub fn with_context<F>(self, configure: F) -> Self
pub fn with_context<F>(self, configure: F) -> Self
Installs context-level runtime support into the boot Cx before dispatch
(e.g. a codec, an eval policy, a supporting lib). Concrete serve behavior
stays in the loaded library.