Struct btrun::Runtime

source ·
pub struct Runtime { /* private fields */ }
Expand description

An actor runtime.

Actors can be activated by the runtime and execute autonomously until they return. Running actors can be sent messages using the send method, which does not wait for a response from the recipient. If a reply is needed, then call can be used, which returns a future that will be ready when the reply has been received.

Implementations§

source§

impl Runtime

source

pub fn path(&self) -> &Arc<BlockPath>

source

pub async fn num_running(&self) -> usize

Returns the number of actors that are currently executing in this Runtime.

source

pub async fn send<T: 'static + SendMsg>( &self, to: ActorName, from: ActorName, msg: T ) -> Result<()>

Sends a message to the actor identified by the given ActorName.

source

pub async fn call<T: 'static + CallMsg>( &self, to: ActorName, from: ActorName, msg: T ) -> Result<T::Reply>

Sends a message to the actor identified by the given ActorName and returns a future which is ready when a reply has been received.

source

pub async fn resolve<'a>(&'a self, _service: &ServiceName) -> Result<ActorName>

Resolves the given ServiceName to an ActorName which is part of it.

source

pub async fn activate<Msg, F, Fut>(&'static self, activator: F) -> ActorNamewhere Msg: 'static + CallMsg, Fut: 'static + Send + Future<Output = ()>, F: FnOnce(&'static Runtime, Receiver<Envelope<Msg>>, Uuid) -> Fut,

Activates a new actor using the given activator function and returns a handle to it.

source

pub async fn register<Msg, Fut, F, G>( &self, _id: ServiceId, _activator: F, _deserializer: G ) -> Result<()>where Msg: 'static + CallMsg, Fut: 'static + Send + Future<Output = ()>, F: Fn(Receiver<Envelope<Msg>>, Uuid) -> Fut, G: 'static + Send + Sync + Fn(&[u8]) -> Result<Msg>,

Registers an actor as a service with the given ServiceId.

source

pub async fn take(&self, name: &ActorName) -> Result<ActorHandle>

Returns the ActorHandle for the actor with the given name.

If there is no such actor in this runtime then a RuntimeError::BadActorName error is returned.

Note that the actor will be aborted when the given handle is dropped (unless it has already returned when the handle is dropped), and no further messages will be delivered to it by this runtime.

source

pub fn actor_name(&self, act_id: Uuid) -> ActorName

Returns the name of the actor in this runtime with the given actor ID.

Trait Implementations§

source§

impl Drop for Runtime

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Free for T

§

unsafe default fn free(ptr_ref: NonNull<T>)

Drops the content pointed by this pointer and frees it. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more