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;
fn clone_box(&self) -> Box<dyn ProtocolExtension>;
}Expand description
Trait for custom protocol behaviors that can be projected and validated
Required Methods§
Sourcefn mentions_role(&self, role: &Role) -> bool
fn mentions_role(&self, role: &Role) -> bool
Check if this protocol mentions a specific role
Sourcefn validate(&self, roles: &[Role]) -> Result<(), ExtensionValidationError>
fn validate(&self, roles: &[Role]) -> Result<(), ExtensionValidationError>
Validate this protocol against declared roles
Sourcefn project(
&self,
role: &Role,
context: &ProjectionContext<'_>,
) -> Result<LocalType, ProjectionError>
fn project( &self, role: &Role, context: &ProjectionContext<'_>, ) -> Result<LocalType, ProjectionError>
Project this protocol to a local type for a specific role
Sourcefn generate_code(&self, context: &CodegenContext<'_>) -> TokenStream
fn generate_code(&self, context: &CodegenContext<'_>) -> TokenStream
Generate code for this protocol extension
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn type_id(&self) -> TypeId
fn clone_box(&self) -> Box<dyn ProtocolExtension>
Trait Implementations§
Source§impl Clone for Box<dyn ProtocolExtension>
impl Clone for Box<dyn ProtocolExtension>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more