pub trait MutationConverter: Send + Sync {
// Required methods
fn spec_kinds(&self) -> &'static [&'static str];
fn convert_v2(
&self,
spec: &MutationSpec,
ctx: &AnalysisContext,
) -> Result<Vec<Box<dyn ASTRegApply>>, ConvertError>;
// Provided method
fn can_handle(&self, spec: &MutationSpec) -> bool { ... }
}Expand description
Trait for converting MutationSpec to Mutation and applying it
Each implementation handles specific MutationSpec variants. The Registry routes specs to appropriate converters.
§Resolution vs Application
resolve(): Converts spec to mutation and resolves target file via SymbolIdconvert_and_apply(): Legacy method that both converts and applies (deprecated pattern)
New code should use resolve() + batch application via BlueprintExecutor.
Required Methods§
Sourcefn spec_kinds(&self) -> &'static [&'static str]
fn spec_kinds(&self) -> &'static [&'static str]
Returns the spec kind(s) this converter handles e.g., &[“Rename”] or &[“AddField”, “RemoveField”]
Sourcefn convert_v2(
&self,
spec: &MutationSpec,
ctx: &AnalysisContext,
) -> Result<Vec<Box<dyn ASTRegApply>>, ConvertError>
fn convert_v2( &self, spec: &MutationSpec, ctx: &AnalysisContext, ) -> Result<Vec<Box<dyn ASTRegApply>>, ConvertError>
Convert MutationSpec to execution units (V2 API)
Returns a vector of ASTRegApply mutations that implement the spec. One spec may expand to multiple execution units (e.g., AddVariant may also add match arms, AddField may update constructors).
§Design
The 1:N mapping (one spec → multiple mutations) enables:
- Compound operations (AddVariant + AddMatchArm)
- Cascading updates (field addition → constructor updates)
- Atomic multi-location changes
Provided Methods§
Sourcefn can_handle(&self, spec: &MutationSpec) -> bool
fn can_handle(&self, spec: &MutationSpec) -> bool
Check if this converter can handle the given spec
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".