pub trait SubsystemContext: 'static + Send {
type Message: 'static + Debug + Send;
type Signal: 'static + Debug + Send;
type OutgoingMessages: 'static + Debug + Send;
type Sender: 'static + Clone + Send + SubsystemSender<Self::OutgoingMessages>;
type Error: 'static + Error + From<OrchestraError> + Sync + Send;
fn try_recv<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<Option<FromOrchestra<Self::Message, Self::Signal>>, ()>> + Send + 'async_trait, Global>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn recv<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<FromOrchestra<Self::Message, Self::Signal>, Self::Error>> + Send + 'async_trait, Global>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn spawn(
&mut self,
name: &'static str,
s: Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>>
) -> Result<(), Self::Error>;
fn spawn_blocking(
&mut self,
name: &'static str,
s: Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>>
) -> Result<(), Self::Error>;
fn sender(&mut self) -> &mut Self::Sender;
fn send_message<'life0, 'async_trait, T>(
&'life0 mut self,
msg: T
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait, Global>>
where
'life0: 'async_trait,
Self::OutgoingMessages: From<T> + Send,
T: Send + 'async_trait,
Self: 'async_trait,
{ ... }
fn send_messages<'life0, 'async_trait, T, I>(
&'life0 mut self,
msgs: I
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait, Global>>
where
'life0: 'async_trait,
Self::OutgoingMessages: From<T> + Send,
I: IntoIterator<Item = T> + Send + 'async_trait,
<I as IntoIterator>::IntoIter: Send,
T: Send + 'async_trait,
Self: 'async_trait,
{ ... }
fn send_unbounded_message<X>(&mut self, msg: X)
where
Self::OutgoingMessages: From<X> + Send,
X: Send,
{ ... }
}
Expand description
Required Associated Types§
sourcetype Message: 'static + Debug + Send
type Message: 'static + Debug + Send
The message type of this context. Subsystems launched with this context will expect
to receive messages of this type. Commonly uses the wrapping enum
commonly called
AllMessages
.
sourcetype OutgoingMessages: 'static + Debug + Send
type OutgoingMessages: 'static + Debug + Send
The overarching messages enum
for this particular subsystem.
sourcetype Sender: 'static + Clone + Send + SubsystemSender<Self::OutgoingMessages>
type Sender: 'static + Clone + Send + SubsystemSender<Self::OutgoingMessages>
The sender type as provided by sender()
and underlying.
Required Methods§
sourcefn try_recv<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<Option<FromOrchestra<Self::Message, Self::Signal>>, ()>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
Self: 'async_trait,
fn try_recv<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<Option<FromOrchestra<Self::Message, Self::Signal>>, ()>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
Self: 'async_trait,
Try to asynchronously receive a message.
Has to be used with caution, if you loop over this without
using pending!()
macro you will end up with a busy loop!
sourcefn recv<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<FromOrchestra<Self::Message, Self::Signal>, Self::Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
Self: 'async_trait,
fn recv<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<FromOrchestra<Self::Message, Self::Signal>, Self::Error>> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
Self: 'async_trait,
Receive a message.
sourcefn spawn(
&mut self,
name: &'static str,
s: Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>>
) -> Result<(), Self::Error>
fn spawn(
&mut self,
name: &'static str,
s: Pin<Box<dyn Future<Output = ()> + Send + 'static, Global>>
) -> Result<(), Self::Error>
Spawn a child task on the executor.
Provided Methods§
sourcefn send_message<'life0, 'async_trait, T>(
&'life0 mut self,
msg: T
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
Self::OutgoingMessages: From<T> + Send,
T: Send + 'async_trait,
Self: 'async_trait,
fn send_message<'life0, 'async_trait, T>(
&'life0 mut self,
msg: T
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
Self::OutgoingMessages: From<T> + Send,
T: Send + 'async_trait,
Self: 'async_trait,
Send a direct message to some other Subsystem
, routed based on message type.
sourcefn send_messages<'life0, 'async_trait, T, I>(
&'life0 mut self,
msgs: I
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
Self::OutgoingMessages: From<T> + Send,
I: IntoIterator<Item = T> + Send + 'async_trait,
<I as IntoIterator>::IntoIter: Send,
T: Send + 'async_trait,
Self: 'async_trait,
fn send_messages<'life0, 'async_trait, T, I>(
&'life0 mut self,
msgs: I
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait, Global>>where
'life0: 'async_trait,
Self::OutgoingMessages: From<T> + Send,
I: IntoIterator<Item = T> + Send + 'async_trait,
<I as IntoIterator>::IntoIter: Send,
T: Send + 'async_trait,
Self: 'async_trait,
Send multiple direct messages to other Subsystem
s, routed based on message type.
sourcefn send_unbounded_message<X>(&mut self, msg: X)where
Self::OutgoingMessages: From<X> + Send,
X: Send,
fn send_unbounded_message<X>(&mut self, msg: X)where
Self::OutgoingMessages: From<X> + Send,
X: Send,
Send a message using the unbounded connection.