pub struct Environment { /* private fields */ }Expand description
High-level container that owns one or more runtimes, exposes a unified event receiver, and provides lifecycle helpers for running and shutting down the underlying actor system.
Implementations§
Source§impl Environment
impl Environment
Sourcepub fn new(config: Option<EnvironmentConfig>) -> Self
pub fn new(config: Option<EnvironmentConfig>) -> Self
Create a new environment with optional configuration.
Sourcepub async fn register_runtime(
&mut self,
runtime: Arc<dyn Runtime>,
) -> Result<(), Error>
pub async fn register_runtime( &mut self, runtime: Arc<dyn Runtime>, ) -> Result<(), Error>
Register a runtime with this environment and make it the default if none is set yet.
Sourcepub fn config(&self) -> &EnvironmentConfig
pub fn config(&self) -> &EnvironmentConfig
Access the environment configuration.
Sourcepub async fn get_runtime(
&self,
runtime_id: &RuntimeID,
) -> Option<Arc<dyn Runtime>>
pub async fn get_runtime( &self, runtime_id: &RuntimeID, ) -> Option<Arc<dyn Runtime>>
Get a runtime by its id, if present.
Sourcepub async fn get_runtime_or_default(
&self,
runtime_id: Option<RuntimeID>,
) -> Result<Arc<dyn Runtime>, Error>
pub async fn get_runtime_or_default( &self, runtime_id: Option<RuntimeID>, ) -> Result<Arc<dyn Runtime>, Error>
Get the specified runtime or the default one when None is passed.
Sourcepub fn run(&mut self) -> JoinHandle<Result<(), RuntimeError>> ⓘ
pub fn run(&mut self) -> JoinHandle<Result<(), RuntimeError>> ⓘ
Start all registered runtimes and return a handle that resolves when they finish. This will typically run until shutdown is requested.
Sourcepub async fn run_background(&mut self) -> Result<(), RuntimeError>
pub async fn run_background(&mut self) -> Result<(), RuntimeError>
Start all registered runtimes and return immediately without waiting for completion.
Sourcepub async fn take_event_receiver(
&mut self,
runtime_id: Option<RuntimeID>,
) -> Result<BoxEventStream<Event>, EnvironmentError>
pub async fn take_event_receiver( &mut self, runtime_id: Option<RuntimeID>, ) -> Result<BoxEventStream<Event>, EnvironmentError>
Take the event receiver for a specific runtime (or the default one) so the caller can consume protocol events. This can only be taken once.
Auto Trait Implementations§
impl Freeze for Environment
impl !RefUnwindSafe for Environment
impl Send for Environment
impl Sync for Environment
impl Unpin for Environment
impl !UnwindSafe for Environment
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
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