Struct ActorBuilder

Source
pub struct ActorBuilder<T, A: ActorState> { /* private fields */ }
Expand description

Holds a type that implements ActorState, helps aggregate all data that the actor needs, and then launches the async actor process. When the actor process is launched, a client is returned to the caller. This client’s type depends on the actor’s type.

Implementations§

Source§

impl<T, A> ActorBuilder<T, A>
where A: ActorState<ActorType = T>,

Source

pub fn new(state: A) -> Self

Constructs a new builder for an actor that uses the given state.

Source

pub fn attach_stream<S, I>(&mut self, stream: S)
where S: SendableFusedStream<Item = I>, I: Into<A::Message>,

Attaches a stream that will be used by the actor once its spawned. No messages will be processed until after the actor is launched.

Source§

impl<A> ActorBuilder<SinkActor, A>
where A: ActorState<ActorType = SinkActor>,

Source

pub fn client(&self) -> SinkClient<A::Permanence, A::Message>

Returns a client for the actor that will be spawned. While the returned client will be able to send messages, those messages will not be processed until after the actor is launched by the builder.

Source

pub fn launch(self) -> SinkClient<A::Permanence, A::Message>

Launches an actor that uses the given state and returns a client to the actor.

Source§

impl<A> ActorBuilder<StreamActor, A>
where A: ActorState<ActorType = StreamActor>,

Source

pub fn client(&mut self) -> StreamClient<A::Output>

Returns a client for the actor that will be spawned. The client will not yield any messages until after the actor is launched and has sent a message.

Source

pub fn launch<S>(self, stream: S) -> StreamClient<A::Output>
where S: SendableFusedStream<Item = A::Message>,

Launches an actor that uses the given state. Returns a client to the actor.

Source§

impl<A> ActorBuilder<JointActor, A>
where A: ActorState<ActorType = JointActor>,

Source

pub fn stream_client(&self) -> StreamClient<A::Output>

Returns a stream client for the actor that will be spawned. The client will not yield any messages until after the actor is launched and has sent a message.

Source

pub fn sink_client(&self) -> SinkClient<A::Permanence, A::Message>

Returns a sink client for the actor that will be spawned. While the returned client will be able to send messages, those messages will not be processed until after the actor is launched by the builder.

Source

pub fn client(&self) -> SinkClient<A::Permanence, A::Message>

Returns a joint client for the actor that will be spawned. While the returned client will be able to send messages, those messages will not be processed until after the actor is launched by the builder. The client will also not yield any messages until after the actor is launched and has sent a message.

Source

pub fn launch_with_stream<S>( self, stream: S, ) -> JointClient<A::Permanence, A::Message, A::Output>
where S: SendableFusedStream<Item = A::Message>,

Launches an actor that uses the given state and stream. Returns a client to the actor.

Source

pub fn launch(self) -> JointClient<A::Permanence, A::Message, A::Output>

Launches an actor that uses the given state. Returns a client to the actor.

Auto Trait Implementations§

§

impl<T, A> Freeze for ActorBuilder<T, A>
where A: Freeze,

§

impl<T, A> !RefUnwindSafe for ActorBuilder<T, A>

§

impl<T, A> Send for ActorBuilder<T, A>
where T: Send,

§

impl<T, A> !Sync for ActorBuilder<T, A>

§

impl<T, A> Unpin for ActorBuilder<T, A>
where A: Unpin, T: Unpin,

§

impl<T, A> !UnwindSafe for ActorBuilder<T, A>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<T> Sendable for T
where T: 'static + Send,