Workspace

Trait Workspace 

Source
pub trait Workspace: Send + Sync {
    // Required methods
    fn services(&self) -> &WorkspaceServices;
    fn set_services(&mut self, services: WorkspaceServices);
    fn boot<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        rt: &'life1 WorkspaceRuntime,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn run<'life0, 'life1, 'async_trait>(
        &'life0 self,
        rt: &'life1 WorkspaceRuntime,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn on_parent_message<'life0, 'life1, 'async_trait>(
        &'life0 self,
        rt: &'life1 WorkspaceRuntime,
        event: ParentMessageEvent,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn evaluate_spawn_request<'life0, 'life1, 'async_trait>(
        &'life0 self,
        rt: &'life1 WorkspaceRuntime,
        requester: SpawnRequester,
        request: SpawnChildRequest,
    ) -> Pin<Box<dyn Future<Output = Result<SpawnRequestDecision>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn services_needed(&self) -> Vec<(ChildKind, CapabilitySet)> { ... }
}
Expand description

Workspace behavior that can be plugged into WorkspaceRunner.

Implementors should store a WorkspaceServices field and provide access via the services() and set_services() methods. The runner will call set_services() before boot() to inject the started services.

Required Methods§

Source

fn services(&self) -> &WorkspaceServices

Return the services container. Used by helper methods.

Source

fn set_services(&mut self, services: WorkspaceServices)

Set the services container. Called by the runner before boot().

Source

fn boot<'life0, 'life1, 'async_trait>( &'life0 mut self, rt: &'life1 WorkspaceRuntime, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called after the IPC listener is bound and accepting connections.

Source

fn run<'life0, 'life1, 'async_trait>( &'life0 self, rt: &'life1 WorkspaceRuntime, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Main application task for the workspace.

Simply explained:

  • The runner has an internal IPC loop (accepts connections, routes messages, handles spawn/proxy calls).
  • Your run() executes concurrently with that IPC loop.
  • If you want run() to stay alive until shutdown, await rt.wait_for_shutdown() (usually via tokio::select!).

Returning from run() will request workspace shutdown.

Source

fn on_parent_message<'life0, 'life1, 'async_trait>( &'life0 self, rt: &'life1 WorkspaceRuntime, event: ParentMessageEvent, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called for each child-to-parent message.

Source

fn evaluate_spawn_request<'life0, 'life1, 'async_trait>( &'life0 self, rt: &'life1 WorkspaceRuntime, requester: SpawnRequester, request: SpawnChildRequest, ) -> Pin<Box<dyn Future<Output = Result<SpawnRequestDecision>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Evaluate a spawn request.

Provided Methods§

Source

fn services_needed(&self) -> Vec<(ChildKind, CapabilitySet)>

Return the list of singleton services this workspace needs.

The runner will start these services before calling Workspace::boot and inject them via set_services.

Implementors§