pub trait GeneratorPlugin: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn version(&self) -> &str;
fn description(&self) -> &str;
fn config_schema(&self) -> Option<Value>;
fn generate(
&self,
config: &Value,
context: &GenerationContext,
) -> Result<Vec<GeneratedRecord>, SynthError>;
}Expand description
Trait for custom data generator plugins.
Generator plugins produce records based on configuration and context.
§Example
use datasynth_core::traits::plugin::*;
use datasynth_core::error::SynthError;
struct MyGenerator;
impl GeneratorPlugin for MyGenerator {
fn name(&self) -> &str { "my_generator" }
fn version(&self) -> &str { "1.0.0" }
fn description(&self) -> &str { "Generates custom records" }
fn config_schema(&self) -> Option<serde_json::Value> { None }
fn generate(
&self,
_config: &serde_json::Value,
_context: &GenerationContext,
) -> Result<Vec<GeneratedRecord>, SynthError> {
Ok(vec![GeneratedRecord::new("custom").with_field("key", "value")])
}
}Required Methods§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Human-readable description.
Sourcefn config_schema(&self) -> Option<Value>
fn config_schema(&self) -> Option<Value>
Optional JSON Schema for plugin configuration.
Sourcefn generate(
&self,
config: &Value,
context: &GenerationContext,
) -> Result<Vec<GeneratedRecord>, SynthError>
fn generate( &self, config: &Value, context: &GenerationContext, ) -> Result<Vec<GeneratedRecord>, SynthError>
Generate records given configuration and context.