pub trait ConductorHostRole: Role<Counterpart: HasPeer<Client>> {
type Instantiator: Send;
// Required methods
fn initialize(
&self,
message: Dispatch,
connection: ConnectionTo<Self::Counterpart>,
instantiator: Self::Instantiator,
responder: &mut ConductorResponder<Self>,
) -> impl Future<Output = Result<Dispatch, Error>> + Send;
fn handle_dispatch(
&self,
message: Dispatch,
connection: ConnectionTo<Self::Counterpart>,
conductor_tx: &mut Sender<ConductorMessage>,
) -> impl Future<Output = Result<Handled<Dispatch>, Error>> + Send;
}Expand description
Trait implemented for the two links the conductor can use:
- ConductorToClient – conductor is acting as an agent, so when its last proxy sends to its successor, the conductor sends that message to its agent component
- ConductorToConductor – conductor is acting as a proxy, so when its last proxy sends to its successor, the (inner) conductor sends that message to its successor, via the outer conductor
Required Associated Types§
Sourcetype Instantiator: Send
type Instantiator: Send
The type used to instantiate components for this link type.
Required Methods§
Sourcefn initialize(
&self,
message: Dispatch,
connection: ConnectionTo<Self::Counterpart>,
instantiator: Self::Instantiator,
responder: &mut ConductorResponder<Self>,
) -> impl Future<Output = Result<Dispatch, Error>> + Send
fn initialize( &self, message: Dispatch, connection: ConnectionTo<Self::Counterpart>, instantiator: Self::Instantiator, responder: &mut ConductorResponder<Self>, ) -> impl Future<Output = Result<Dispatch, Error>> + Send
Handle initialization: parse the init request, instantiate components, and spawn them.
Takes ownership of the instantiator and returns the (possibly modified) init request wrapped in a Dispatch for forwarding.
Sourcefn handle_dispatch(
&self,
message: Dispatch,
connection: ConnectionTo<Self::Counterpart>,
conductor_tx: &mut Sender<ConductorMessage>,
) -> impl Future<Output = Result<Handled<Dispatch>, Error>> + Send
fn handle_dispatch( &self, message: Dispatch, connection: ConnectionTo<Self::Counterpart>, conductor_tx: &mut Sender<ConductorMessage>, ) -> impl Future<Output = Result<Handled<Dispatch>, Error>> + Send
Handle an incoming message from the client or conductor, depending on Self
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.
Implementations on Foreign Types§
Source§impl ConductorHostRole for Agent
Conductor acting as an agent
impl ConductorHostRole for Agent
Conductor acting as an agent
type Instantiator = Box<dyn InstantiateProxiesAndAgent>
async fn initialize( &self, message: Dispatch, client_connection: ConnectionTo<Client>, instantiator: Self::Instantiator, responder: &mut ConductorResponder<Self>, ) -> Result<Dispatch, Error>
async fn handle_dispatch( &self, message: Dispatch, client_connection: ConnectionTo<Client>, conductor_tx: &mut Sender<ConductorMessage>, ) -> Result<Handled<Dispatch>, Error>
Source§impl ConductorHostRole for Proxy
Conductor acting as a proxy
impl ConductorHostRole for Proxy
Conductor acting as a proxy