Skip to main content

MicrodeApplication

Composes installed modules and coordinates their lifecycle.

Methods​

new​

pub fn new() -> Self

Creates an idle service using the production module context. Default::default() is equivalent.

state​

pub fn state(&self) -> MicrodeApplicationState

Returns the service's current lifecycle state.

install​

pub fn install<M, F>(&mut self, factory: F) -> Result<(), MicrodeError>
where
M: MicrodeModule + 'static,
F: FnOnce(MicrodeContextHandle) -> M

Installs an unnamed module. Use this when the module does not participate in explicit relationship binding.

install_named​

pub fn install_named<M, F>(
&mut self,
id: impl Into<String>,
factory: F,
) -> Result<ModuleHandle<M>, MicrodeError>
where
M: MicrodeModule + 'static,
F: FnOnce(MicrodeContextHandle) -> M

Installs a module under a unique stable ID and returns the handle used by bind.

bind​

pub fn bind(
&mut self,
consumer: &dyn ModuleHandleIdentity,
slot: &dyn RelationshipSlot,
target: &dyn ModuleHandleIdentity,
) -> Result<(), MicrodeError>

Binds one declared relationship on consumer to a provider exported by target. Both handles must belong to this service.

serve​

pub fn serve(
&mut self,
) -> BoxFuture<'static, Result<MicrodeExecutionResult, MicrodeError>>

Seals and validates the composition, starts the module-driven lifecycle immediately, and returns an owned completion future. Dropping the future does not cancel execution.

run​

pub fn run<Main, MainFuture>(
&mut self,
main: Main,
) -> BoxFuture<'static, Result<MicrodeExecutionResult, MicrodeError>>

Starts the modules and then invokes main. Completion or failure of main begins orderly shutdown. An application can execute only once.

stop​

pub fn stop(
&self,
request: MicrodeStopRequest,
) -> BoxFuture<'static, Result<MicrodeExecutionResult, MicrodeError>>

Requests an orderly stop and waits for the shared completion result. The first stop request wins.