pub trait MutationConverter: Send + Sync {
// Required method
fn spec_kinds(&self) -> &'static [&'static str];
// Provided methods
fn can_handle(&self, spec: &MutationSpec) -> bool { ... }
fn convert(
&self,
_spec: &MutationSpec,
) -> Result<Box<dyn Mutation>, ConvertError> { ... }
fn convert_v2(
&self,
_spec: &MutationSpec,
_ctx: &AnalysisContext,
) -> Result<Vec<Box<dyn ASTRegApply>>, ConvertError> { ... }
}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”]
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
Sourcefn convert(
&self,
_spec: &MutationSpec,
) -> Result<Box<dyn Mutation>, ConvertError>
👎Deprecated since 0.1.0: Returns Box<dyn Mutation> for legacy apply(&mut PureFile). Use convert_v2() for ASTRegApply.
fn convert( &self, _spec: &MutationSpec, ) -> Result<Box<dyn Mutation>, ConvertError>
Returns Box<dyn Mutation> for legacy apply(&mut PureFile). Use convert_v2() for ASTRegApply.
Convert a MutationSpec to a Mutation (DEPRECATED - use convert_v2 instead)
This method is deprecated and will be removed in a future version.
Use convert_v2() which returns ASTRegApply mutations instead.
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
§Default Implementation
Returns Err(ConvertError::V2NotSupported) to allow gradual migration.
Converters should override this to provide V2 support.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".