Skip to main content

Role

Trait Role 

Source
pub trait Role:
    Debug
    + Clone
    + Send
    + Sync
    + 'static
    + Eq
    + Ord
    + Hash {
    type Counterpart: Role<Counterpart = Self>;

    // Required methods
    fn role_id(&self) -> RoleId;
    fn default_handle_dispatch_from(
        &self,
        message: Dispatch,
        connection: ConnectionTo<Self>,
    ) -> impl Future<Output = Result<Handled<Dispatch>, Error>> + Send;
    fn counterpart(&self) -> Self::Counterpart;

    // Provided method
    fn builder(self) -> Builder<Self>
       where Self: Sized { ... }
}
Expand description

The role that an endpoint plays in an ACP connection.

Roles are the fundamental building blocks of ACP’s type system:

Each role determines:

  • Who the counterpart is (via Role::Counterpart)
  • How unhandled messages are processed (via Role::default_message_handler)

Required Associated Types§

Source

type Counterpart: Role<Counterpart = Self>

The role that this endpoint connects to.

For example:

  • Client::Counterpart = Agent
  • Agent::Counterpart = Client
  • Proxy::Counterpart = Conductor
  • Conductor::Counterpart = Proxy

Required Methods§

Source

fn role_id(&self) -> RoleId

Returns a unique identifier for this role.

Source

fn default_handle_dispatch_from( &self, message: Dispatch, connection: ConnectionTo<Self>, ) -> impl Future<Output = Result<Handled<Dispatch>, Error>> + Send

Method invoked when there is no defined message handler.

Source

fn counterpart(&self) -> Self::Counterpart

Returns the counterpart role.

Provided Methods§

Source

fn builder(self) -> Builder<Self>
where Self: Sized,

Creates a new builder playing this role.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§