DataSourcePlugin

Trait DataSourcePlugin 

Source
pub trait DataSourcePlugin: Send + Sync {
    // Required methods
    fn capabilities(&self) -> PluginCapabilities;
    fn initialize<'life0, 'life1, 'async_trait>(
        &'life0 self,
        config: &'life1 DataSourcePluginConfig,
    ) -> Pin<Box<dyn Future<Output = Result<(), PluginError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
    fn connect<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        context: &'life1 PluginContext,
        config: &'life2 DataSourcePluginConfig,
    ) -> Pin<Box<dyn Future<Output = Result<PluginResult<DataConnection>, PluginError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait;
    fn query<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
        &'life0 self,
        context: &'life1 PluginContext,
        connection: &'life2 DataConnection,
        query: &'life3 DataQuery,
        config: &'life4 DataSourcePluginConfig,
    ) -> Pin<Box<dyn Future<Output = Result<PluginResult<DataResult>, PluginError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             'life4: 'async_trait,
             Self: 'async_trait;
    fn get_schema<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        context: &'life1 PluginContext,
        connection: &'life2 DataConnection,
        config: &'life3 DataSourcePluginConfig,
    ) -> Pin<Box<dyn Future<Output = Result<PluginResult<Schema>, PluginError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait,
             Self: 'async_trait;
    fn test_connection<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        context: &'life1 PluginContext,
        config: &'life2 DataSourcePluginConfig,
    ) -> Pin<Box<dyn Future<Output = Result<PluginResult<ConnectionTestResult>, PluginError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait;
    fn validate_config(
        &self,
        config: &DataSourcePluginConfig,
    ) -> Result<(), PluginError>;
    fn supported_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

Data source plugin trait

Implement this trait to create custom data source integrations. Data source plugins enable MockForge to connect to external data sources like databases, REST APIs, files, and other systems for dynamic mocking.

Required Methods§

Source

fn capabilities(&self) -> PluginCapabilities

Get plugin capabilities (permissions and limits)

Source

fn initialize<'life0, 'life1, 'async_trait>( &'life0 self, config: &'life1 DataSourcePluginConfig, ) -> 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 connect<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, context: &'life1 PluginContext, config: &'life2 DataSourcePluginConfig, ) -> Pin<Box<dyn Future<Output = Result<PluginResult<DataConnection>, PluginError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Connect to the data source

This method establishes a connection to the data source using the provided configuration.

§Arguments
  • context - Plugin execution context
  • config - Data source configuration
§Returns

Connection handle

Source

fn query<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>( &'life0 self, context: &'life1 PluginContext, connection: &'life2 DataConnection, query: &'life3 DataQuery, config: &'life4 DataSourcePluginConfig, ) -> Pin<Box<dyn Future<Output = Result<PluginResult<DataResult>, PluginError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, Self: 'async_trait,

Execute a query against the data source

This method executes a query using the provided connection.

§Arguments
  • context - Plugin execution context
  • connection - Active connection
  • query - Query to execute
  • config - Data source configuration
§Returns

Query results

Source

fn get_schema<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, context: &'life1 PluginContext, connection: &'life2 DataConnection, config: &'life3 DataSourcePluginConfig, ) -> Pin<Box<dyn Future<Output = Result<PluginResult<Schema>, PluginError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, Self: 'async_trait,

Get data source schema information

This method retrieves schema information about the data source, such as available tables, columns, and relationships.

§Arguments
  • context - Plugin execution context
  • connection - Active connection
  • config - Data source configuration
§Returns

Schema information

Source

fn test_connection<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, context: &'life1 PluginContext, config: &'life2 DataSourcePluginConfig, ) -> Pin<Box<dyn Future<Output = Result<PluginResult<ConnectionTestResult>, PluginError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Test the data source connection

This method tests whether the data source is accessible and the configuration is correct.

§Arguments
  • context - Plugin execution context
  • config - Data source configuration
§Returns

Connection test result

Source

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

Validate plugin configuration

Source

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

Get supported data source 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§