Skip to main content

ProtocolExtension

Trait ProtocolExtension 

Source
pub trait ProtocolExtension:
    Send
    + Sync
    + Debug {
    // Required methods
    fn type_name(&self) -> &'static str;
    fn mentions_role(&self, role: &Role) -> bool;
    fn validate(&self, roles: &[Role]) -> Result<(), ExtensionValidationError>;
    fn project(
        &self,
        role: &Role,
        context: &ProjectionContext<'_>,
    ) -> Result<LocalType, ProjectionError>;
    fn generate_code(&self, context: &CodegenContext<'_>) -> TokenStream;
    fn as_any(&self) -> &(dyn Any + 'static);
    fn as_any_mut(&mut self) -> &mut (dyn Any + 'static);
    fn type_id(&self) -> TypeId;
}
Expand description

Trait for custom protocol behaviors that can be projected and validated

Required Methods§

Source

fn type_name(&self) -> &'static str

Unique identifier for this protocol extension type

Source

fn mentions_role(&self, role: &Role) -> bool

Check if this protocol mentions a specific role

Source

fn validate(&self, roles: &[Role]) -> Result<(), ExtensionValidationError>

Validate this protocol against declared roles

Source

fn project( &self, role: &Role, context: &ProjectionContext<'_>, ) -> Result<LocalType, ProjectionError>

Project this protocol to a local type for a specific role

Source

fn generate_code(&self, context: &CodegenContext<'_>) -> TokenStream

Generate code for this protocol extension

Source

fn as_any(&self) -> &(dyn Any + 'static)

For trait object safety and downcasting

Source

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Source

fn type_id(&self) -> TypeId

Implementors§