referrerpolicy=no-referrer-when-downgrade
polkadot_overseer

Trait SubsystemContext

pub trait SubsystemContext: Send + 'static {
    type Message: Debug + Send + 'static;
    type Signal: Debug + Send + 'static;
    type OutgoingMessages: Debug + Send + 'static;
    type Sender: Clone + Send + 'static + SubsystemSender<Self::OutgoingMessages>;
    type Error: Error + From<OrchestraError> + Sync + Send + 'static;

    // Required methods
    fn try_recv<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<Option<FromOrchestra<Self::Message, Self::Signal>>, ()>> + Send + 'async_trait>>
       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>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn recv_signal<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Signal, Self::Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn spawn(
        &mut self,
        name: &'static str,
        s: Pin<Box<dyn Future<Output = ()> + Send>>,
    ) -> Result<(), Self::Error>;
    fn spawn_blocking(
        &mut self,
        name: &'static str,
        s: Pin<Box<dyn Future<Output = ()> + Send>>,
    ) -> Result<(), Self::Error>;
    fn sender(&mut self) -> &mut Self::Sender;

    // Provided methods
    fn send_message<'life0, 'async_trait, T>(
        &'life0 mut self,
        msg: T,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       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>>
       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

A context type that is given to the Subsystem upon spawning. It can be used by Subsystem to communicate with other Subsystems or spawn jobs.

Required Associated Types§

type Message: Debug + Send + 'static

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.

type Signal: Debug + Send + 'static

And the same for signals.

type OutgoingMessages: Debug + Send + 'static

The overarching messages enum for this particular subsystem.

type Sender: Clone + Send + 'static + SubsystemSender<Self::OutgoingMessages>

The sender type as provided by sender() and underlying.

type Error: Error + From<OrchestraError> + Sync + Send + 'static

The error type.

Required Methods§

fn try_recv<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<Option<FromOrchestra<Self::Message, Self::Signal>>, ()>> + Send + 'async_trait>>
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!

fn recv<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<FromOrchestra<Self::Message, Self::Signal>, Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Receive a signal or a message.

fn recv_signal<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<Self::Signal, Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Receive a signal.

This method allows the subsystem to process signals while being blocked on processing messages. See examples/backpressure.rs for an example.

fn spawn( &mut self, name: &'static str, s: Pin<Box<dyn Future<Output = ()> + Send>>, ) -> Result<(), Self::Error>

Spawn a child task on the executor.

fn spawn_blocking( &mut self, name: &'static str, s: Pin<Box<dyn Future<Output = ()> + Send>>, ) -> Result<(), Self::Error>

Spawn a blocking child task on the executor’s dedicated thread pool.

fn sender(&mut self) -> &mut Self::Sender

Obtain the sender.

Provided Methods§

fn send_message<'life0, 'async_trait, T>( &'life0 mut self, msg: T, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
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.

fn send_messages<'life0, 'async_trait, T, I>( &'life0 mut self, msgs: I, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
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 Subsystems, routed based on message type.

fn send_unbounded_message<X>(&mut self, msg: X)
where Self::OutgoingMessages: From<X> + Send, X: Send,

Send a message using the unbounded connection.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl SubsystemContext for OverseerSubsystemContext<ApprovalDistributionMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<ApprovalVotingMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<ApprovalVotingParallelMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<AvailabilityDistributionMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<AvailabilityRecoveryMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<AvailabilityStoreMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<BitfieldDistributionMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<CandidateBackingMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<CandidateValidationMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<ChainApiMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<ChainSelectionMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<CollationGenerationMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<CollatorProtocolMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<DisputeCoordinatorMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<DisputeDistributionMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<GossipSupportMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<NetworkBridgeRxMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<NetworkBridgeTxMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<ProspectiveParachainsMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<ProvisionerMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<RuntimeApiMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<StatementDistributionMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<BitfieldSigningMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<PvfCheckerMessage>

Source§

impl SubsystemContext for OverseerSubsystemContext<()>
where (): AssociateOutgoing + Debug + Send + 'static, AllMessages: From<()>,

impl<Context, Fil> SubsystemContext for InterceptedContext<Context, Fil>
where Context: SubsystemContext<Error = SubsystemError, Signal = OverseerSignal>, <Context as SubsystemContext>::Message: AssociateOutgoing, <Context as SubsystemContext>::Sender: SubsystemSender<<<Context as SubsystemContext>::Message as AssociateOutgoing>::OutgoingMessages>, InterceptedSender<<Context as SubsystemContext>::Sender, Fil>: SubsystemSender<<<Context as SubsystemContext>::Message as AssociateOutgoing>::OutgoingMessages>, Fil: MessageInterceptor<<Context as SubsystemContext>::Sender, Message = <Context as SubsystemContext>::Message>,

impl<M, Spawner> SubsystemContext for TestSubsystemContext<M, Spawner>
where M: AssociateOutgoing + Debug + Send + 'static, AllMessages: From<<M as AssociateOutgoing>::OutgoingMessages> + From<M>, Spawner: Spawner + Send + 'static,