Type Alias Runtime

Source
pub type Runtime = Arc<RuntimeImpl>;

Aliased Type§

struct Runtime { /* private fields */ }

Trait Implementations§

Source§

impl RuntimeTrait for Runtime

Source§

fn create<'async_trait>( id: RuntimeId, ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
where Self: 'async_trait,

Creates a new runtime with the specified ID.

The Runtime maintains a registry of message executors and an internal channel for scheduling message processing.

Source§

fn execute<'life0, 'async_trait, F>( &'life0 self, target_id: RuntimeId, f: F, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where F: Future<Output = Result<()>> + Send + 'static + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Executes a user-defined future within an RPC server context.

Spawns the provided future f within a task-local RPC context for the given target_id. Incoming RPC requests for this target_id are dispatched to registered handlers. If an internal error is reported, the execution is aborted.

Source§

fn execute_local<'life0, 'async_trait, F>( &'life0 self, f: F, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where F: Future<Output = Result<()>> + Send + 'static + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Convenience wrapper around [execute] that targets the current runtime itself.

Source§

fn register_handler<'life0, 'async_trait, H>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where H: 'async_trait + MessageHandler, Self: 'async_trait, 'life0: 'async_trait,

Registers a message handler type with the runtime.

The handler H must implement MessageHandler. After registration, the runtime will deserialize incoming messages of H::Input type, invoke H::handle, and serialize the resulting H::Output.

Source§

fn register_instance<'life0, 'async_trait, T>( &'life0 self, instance: T, ) -> Pin<Box<dyn Future<Output = ObjectRef<T>> + Send + 'async_trait>>
where T: Identity + Any + Send + Sync + 'static + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Registers an object that implements Identity in the runtime-wide registry and returns an ObjectRef that can be shared across runtimes.

Source§

fn get_instance<'life0, 'async_trait, T>( &'life0 self, id: InstanceId, ) -> Pin<Box<dyn Future<Output = Result<Arc<RwLock<T>>, String>> + Send + 'async_trait>>
where T: Identity + Any + Send + Sync + 'static + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Attempts to retrieve a previously registered instance by its InstanceId.

Returns Ok with a shared Arc<RwLock<T>> if the instance exists and can be down‑cast to the requested concrete type; otherwise returns an Err explaining what went wrong.

Source§

fn take_instance<'life0, 'async_trait, T>( &'life0 self, id: InstanceId, ) -> Pin<Box<dyn Future<Output = Option<T>> + Send + 'async_trait>>
where T: Identity + Any + Send + Sync + 'static + 'async_trait, Self: 'async_trait, 'life0: 'async_trait,

Attempts to take a previously registered instance by its InstanceId. Returns Some if the instance exists and can be down-cast to the requested concrete type. Removes the instance from the registry.

Source§

fn call<'life0, 'async_trait, T>( &'life0 self, target_id: RuntimeId, args: T::Input, ) -> Pin<Box<dyn Future<Output = Result<T::Output>> + Send + 'async_trait>>
where T: 'async_trait + MessageHandler, Self: 'async_trait, 'life0: 'async_trait,

Sends an RPC request and awaits its response.

Serializes the provided args into a message, sends it to the target runtime identified by target_id, and deserializes the response into T::Output.

Source§

fn inventory<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Vec<InventoryItem>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns a vec of all registered rpc handlers