ResponsePlugin

Trait ResponsePlugin 

Source
pub trait ResponsePlugin: Send + Sync {
    // Required methods
    fn capabilities(&self) -> PluginCapabilities;
    fn initialize<'life0, 'life1, 'async_trait>(
        &'life0 self,
        config: &'life1 ResponsePluginConfig,
    ) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn can_handle<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        context: &'life1 PluginContext,
        request: &'life2 ResponseRequest,
        config: &'life3 ResponsePluginConfig,
    ) -> Pin<Box<dyn Future<Output = Result<PluginResult<bool>, PluginError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             Self: 'async_trait;
    fn generate_response<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        context: &'life1 PluginContext,
        request: &'life2 ResponseRequest,
        config: &'life3 ResponsePluginConfig,
    ) -> Pin<Box<dyn Future<Output = Result<PluginResult<ResponseData>, PluginError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             Self: 'async_trait;
    fn priority(&self) -> i32;
    fn validate_config(
        &self,
        config: &ResponsePluginConfig,
    ) -> Result<(), PluginError>;
    fn supported_content_types(&self) -> Vec<String>;
    fn cleanup<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
}
Expand description

Response generator plugin trait

Implement this trait to create custom response generation logic. Response plugins are called during the mock response generation phase to create dynamic responses based on request context and custom logic.

Required Methods§

Source

fn capabilities(&self) -> PluginCapabilities

Get plugin capabilities (permissions and limits)

Source

fn initialize<'life0, 'life1, 'async_trait>( &'life0 self, config: &'life1 ResponsePluginConfig, ) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Initialize the plugin with configuration

Source

fn can_handle<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, context: &'life1 PluginContext, request: &'life2 ResponseRequest, config: &'life3 ResponsePluginConfig, ) -> Pin<Box<dyn Future<Output = Result<PluginResult<bool>, PluginError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: 'async_trait,

Check if this plugin can handle the given request

This method is called to determine if the plugin should be used to generate a response for the current request.

§Arguments
  • context - Plugin execution context
  • request - Request information
  • config - Plugin configuration
§Returns

True if this plugin can handle the request

Source

fn generate_response<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, context: &'life1 PluginContext, request: &'life2 ResponseRequest, config: &'life3 ResponsePluginConfig, ) -> Pin<Box<dyn Future<Output = Result<PluginResult<ResponseData>, PluginError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: 'async_trait,

Generate a response for the given request

This method is called when the plugin has indicated it can handle the request. It should generate an appropriate response.

§Arguments
  • context - Plugin execution context
  • request - Request information
  • config - Plugin configuration
§Returns

Generated response

Source

fn priority(&self) -> i32

Get plugin priority (lower numbers = higher priority)

Source

fn validate_config( &self, config: &ResponsePluginConfig, ) -> Result<(), PluginError>

Validate plugin configuration

Source

fn supported_content_types(&self) -> Vec<String>

Get supported content types

Source

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

Cleanup plugin resources

Implementors§