Skip to main content

TargetAdapter

Trait TargetAdapter 

Source
pub trait TargetAdapter:
    Debug
    + Send
    + Sync {
    // 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 write_config_entries(
        &self,
        _entries: &[ConfigEntry],
        _target_dir: &Path,
    ) -> Result<Vec<PathBuf>, MarsError> { ... }
    fn emit_pre_write_diagnostics(
        &self,
        _entries: &[ConfigEntry],
        _diag: &mut DiagnosticCollector,
    ) { ... }
    fn remove_config_entries(
        &self,
        _entry_keys: &[String],
        _target_dir: &Path,
    ) -> Result<(), MarsError> { ... }
}
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§

Source

fn name(&self) -> &str

Target root name (e.g., .claude, .codex).

Source

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.

Source

fn default_dest_path(&self, kind: ItemKind, name: &str) -> Option<DestPath>

Default destination path for an item of the given kind and name.

Returns None if this target does not accept the item kind. The compiler MUST skip items for which this returns None.

Provided Methods§

Source

fn write_config_entries( &self, _entries: &[ConfigEntry], _target_dir: &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.

Source

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.

Source

fn remove_config_entries( &self, _entry_keys: &[String], _target_dir: &Path, ) -> Result<(), MarsError>

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".

Implementors§