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§
Sourcefn capabilities(&self) -> PluginCapabilities
fn capabilities(&self) -> PluginCapabilities
Get plugin capabilities (permissions and limits)
Sourcefn 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 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
Sourcefn 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 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 contextrequest
- Request informationconfig
- Plugin configuration
§Returns
True if this plugin can handle the request
Sourcefn 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 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,
Sourcefn validate_config(
&self,
config: &ResponsePluginConfig,
) -> Result<(), PluginError>
fn validate_config( &self, config: &ResponsePluginConfig, ) -> Result<(), PluginError>
Validate plugin configuration
Sourcefn supported_content_types(&self) -> Vec<String>
fn supported_content_types(&self) -> Vec<String>
Get supported content types