pub trait TargetAdapter:
Debug
+ Send
+ Sync {
Show 13 methods
// Required methods
fn name(&self) -> &str;
fn skill_variant_key(&self) -> Option<&str>;
fn default_dest_path(&self, kind: ItemKind, name: &str) -> Option<DestPath>;
// Provided methods
fn known_hook_events(&self) -> Option<&'static [&'static str]> { ... }
fn hook_fragment_mode(&self) -> Option<HookFragmentMode> { ... }
fn hook_file_dest_path(&self, _name: &str) -> Option<PathBuf> { ... }
fn write_config_entries(
&self,
write: ConfigWrite<'_>,
project_root: &Path,
) -> Result<Vec<PathBuf>, MarsError> { ... }
fn mcp_config_file_names(&self) -> &'static [&'static str] { ... }
fn hook_config_file_names(&self) -> &'static [&'static str] { ... }
fn legacy_hook_config_file_names(&self) -> &'static [&'static str] { ... }
fn emit_pre_write_diagnostics(
&self,
_entries: &[ConfigEntry],
_diag: &mut DiagnosticCollector,
) { ... }
fn remove_owned_hook_entries(
&self,
operation: RemovalOperation<'_>,
project_root: &Path,
_diag: &mut DiagnosticCollector,
) -> RemovalReport { ... }
fn remove_config_entries(
&self,
operation: RemovalOperation<'_>,
project_root: &Path,
) -> RemovalReport { ... }
}Expand description
Per-target compilation adapter.
Implementations encapsulate all per-target knowledge:
- Which item kinds this target accepts
- Default destination path layout
- Config-entry format (future: MCP, hooks, model aliases)
The trait is split into file-output surfaces and config-entry surfaces so parallel pipeline lanes can own disjoint write responsibilities without interfering with each other.
§Object safety
All methods take &self and return concrete types to ensure the trait can
be used as dyn TargetAdapter.
Required Methods§
Sourcefn skill_variant_key(&self) -> Option<&str>
fn skill_variant_key(&self) -> Option<&str>
Skill variant harness key used when projecting skills to this target.
Native harness targets return the variants/<key>/ directory name they
consume. Full-fidelity targets that should not select skill variants
return None.
Provided Methods§
Sourcefn known_hook_events(&self) -> Option<&'static [&'static str]>
fn known_hook_events(&self) -> Option<&'static [&'static str]>
Documented native command-hook events, or None when this target has
no declarative command-hook mechanism.
Sourcefn hook_fragment_mode(&self) -> Option<HookFragmentMode>
fn hook_fragment_mode(&self) -> Option<HookFragmentMode>
Native fragment placement mechanism declared by this adapter.
Sourcefn hook_file_dest_path(&self, _name: &str) -> Option<PathBuf>
fn hook_file_dest_path(&self, _name: &str) -> Option<PathBuf>
Relative destination for an opaque file-mode fragment.
Sourcefn write_config_entries(
&self,
write: ConfigWrite<'_>,
project_root: &Path,
) -> Result<Vec<PathBuf>, MarsError>
fn write_config_entries( &self, write: ConfigWrite<'_>, project_root: &Path, ) -> Result<Vec<PathBuf>, MarsError>
Write config entries (MCP servers, hooks) to this target’s config file.
Returns the paths of files written, for lock tracking. Default: no-op — targets that don’t use a config file leave this as-is.
Sourcefn mcp_config_file_names(&self) -> &'static [&'static str]
fn mcp_config_file_names(&self) -> &'static [&'static str]
Config files mutated by MCP entries.
Sourcefn hook_config_file_names(&self) -> &'static [&'static str]
fn hook_config_file_names(&self) -> &'static [&'static str]
Config files mutated by merge-mode hook entries.
Sourcefn legacy_hook_config_file_names(&self) -> &'static [&'static str]
fn legacy_hook_config_file_names(&self) -> &'static [&'static str]
One-release legacy hook files touched only when old lock records lack structural emission data.
Sourcefn emit_pre_write_diagnostics(
&self,
_entries: &[ConfigEntry],
_diag: &mut DiagnosticCollector,
)
fn emit_pre_write_diagnostics( &self, _entries: &[ConfigEntry], _diag: &mut DiagnosticCollector, )
Emit target-specific pre-write diagnostics (e.g., lossiness warnings).
Called unconditionally before write_config_entries, even on dry runs.
Default: no-op — most targets have no pre-write diagnostics.
Sourcefn remove_owned_hook_entries(
&self,
operation: RemovalOperation<'_>,
project_root: &Path,
_diag: &mut DiagnosticCollector,
) -> RemovalReport
fn remove_owned_hook_entries( &self, operation: RemovalOperation<'_>, project_root: &Path, _diag: &mut DiagnosticCollector, ) -> RemovalReport
Remove hook entries recorded in the previous lock by structural equality.
Sourcefn remove_config_entries(
&self,
operation: RemovalOperation<'_>,
project_root: &Path,
) -> RemovalReport
fn remove_config_entries( &self, operation: RemovalOperation<'_>, project_root: &Path, ) -> RemovalReport
Remove stale config entries from this target’s config file.
entry_keys are the ConfigEntry::key values to remove.
Default: no-op.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".