pub trait Generator: Send + Sync {
// Required methods
fn name(&self) -> &'static str;
fn generate(&self, api: &Api, out_dir: &Utf8Path) -> Result<()>;
// Provided methods
fn generate_with_config(
&self,
api: &Api,
out_dir: &Utf8Path,
_config: &GeneratorConfig,
) -> Result<()> { ... }
fn generate_with_templates(
&self,
api: &Api,
out_dir: &Utf8Path,
config: &GeneratorConfig,
_templates: Option<&TemplateEngine>,
) -> Result<()> { ... }
fn output_files(&self, _api: &Api, _out_dir: &Utf8Path) -> Vec<String> { ... }
fn output_files_with_config(
&self,
api: &Api,
out_dir: &Utf8Path,
_config: &GeneratorConfig,
) -> Vec<String> { ... }
}Expand description
Generators are dispatched in parallel by the orchestrator, so every implementation must be safe to share across threads.