Struct ractor::port::output::OutputPort
source · 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> Default for OutputPort<TMsg>where
TMsg: OutputMessage,
impl<TMsg> Default for OutputPort<TMsg>where
TMsg: OutputMessage,
source§impl<TMsg> Drop for OutputPort<TMsg>where
TMsg: OutputMessage,
impl<TMsg> Drop for OutputPort<TMsg>where
TMsg: OutputMessage,
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> !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> 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