pub trait EmitterPlugin: Send + Sync {
// Required methods
fn language_id(&self) -> &str;
fn language_name(&self) -> &str;
fn version(&self) -> &str;
fn default_output_dir(&self) -> &str;
fn mapper(&self, config: &PluginConfig) -> Box<dyn TypeMapper>;
fn file_extension(&self) -> &str;
// Provided methods
fn config_key(&self) -> &str { ... }
fn api_version(&self) -> u32 { ... }
}Expand description
The core trait that every plugin must implement.
This defines the contract between typewriter and external language emitter plugins.
Each plugin provides metadata about the language it targets and a factory method
for creating the actual TypeMapper implementation.
Required Methods§
Sourcefn language_id(&self) -> &str
fn language_id(&self) -> &str
Unique identifier for this language (e.g. "ruby", "php", "dart").
This is used in #[sync_to(ruby)] and as the TOML section key [ruby].
Sourcefn language_name(&self) -> &str
fn language_name(&self) -> &str
Human-readable display name (e.g. "Ruby", "PHP", "Dart/Flutter").
Sourcefn default_output_dir(&self) -> &str
fn default_output_dir(&self) -> &str
Default output directory when not configured in typewriter.toml.
Sourcefn mapper(&self, config: &PluginConfig) -> Box<dyn TypeMapper>
fn mapper(&self, config: &PluginConfig) -> Box<dyn TypeMapper>
Create a TypeMapper instance for this language.
The returned mapper is used to render type definitions.
The config parameter contains plugin-specific settings from typewriter.toml.
Sourcefn file_extension(&self) -> &str
fn file_extension(&self) -> &str
File extension for generated files (without leading dot).
Used by drift detection and reporting. Defaults to asking the mapper, but can be overridden for cases where the mapper isn’t available yet.
Provided Methods§
Sourcefn config_key(&self) -> &str
fn config_key(&self) -> &str
The TOML section key for this plugin’s configuration.
Defaults to language_id(). Override if you want a different key.
Sourcefn api_version(&self) -> u32
fn api_version(&self) -> u32
Plugin API version this plugin was built against.
Do not override — this is checked at load time for compatibility.