pub struct OutputPort<TMsg>where
TMsg: OutputMessage,{ /* private fields */ }Expand description
An OutputPort is a publish-subscribe mechanism for connecting actors together. It allows actors to emit messages without knowing which downstream actors are subscribed.
You can subscribe to the output port with an ActorRef and a message converter from the output type to the actor’s expected input type. If the actor is dropped or stops, the subscription will be dropped and if the output port is dropped, then the subscription will also be dropped automatically.
Implementations§
Source§impl<TMsg> OutputPort<TMsg>where
TMsg: OutputMessage,
impl<TMsg> OutputPort<TMsg>where
TMsg: OutputMessage,
Sourcepub fn subscribe<TReceiverMsg, F>(
&self,
receiver: ActorRef<TReceiverMsg>,
converter: F,
)
pub fn subscribe<TReceiverMsg, F>( &self, receiver: ActorRef<TReceiverMsg>, converter: F, )
Subscribe to the output port, passing in a converter to convert to the input message of another actor
receiver- The reference to the actor which will receive forwarded messagesconverter- The converter which will convert the output message type to the receiver’s input type and return [Some(_)] if the message should be forwarded, None if the message should be skipped.
Trait Implementations§
Source§impl<TMsg> Debug for OutputPort<TMsg>where
TMsg: OutputMessage,
impl<TMsg> Debug for OutputPort<TMsg>where
TMsg: OutputMessage,
Source§impl<TMsg> Default for OutputPort<TMsg>where
TMsg: OutputMessage,
impl<TMsg> Default for OutputPort<TMsg>where
TMsg: OutputMessage,
Source§fn default() -> OutputPort<TMsg>
fn default() -> OutputPort<TMsg>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<TMsg> !Freeze for OutputPort<TMsg>
impl<TMsg> !RefUnwindSafe for OutputPort<TMsg>
impl<TMsg> Send for OutputPort<TMsg>
impl<TMsg> Sync for OutputPort<TMsg>
impl<TMsg> Unpin for OutputPort<TMsg>
impl<TMsg> UnsafeUnpin for OutputPort<TMsg>
impl<TMsg> !UnwindSafe for OutputPort<TMsg>
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 moreSource§impl<T> Message for T
impl<T> Message for T
Source§fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
Convert a BoxedMessage to this concrete type
Source§fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
Convert this message to a BoxedMessage