Skip to main content

TargetAdapter

Trait TargetAdapter 

Source
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§

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 known_hook_events(&self) -> Option<&'static [&'static str]>

Documented native command-hook events, or None when this target has no declarative command-hook mechanism.

Source

fn hook_fragment_mode(&self) -> Option<HookFragmentMode>

Native fragment placement mechanism declared by this adapter.

Source

fn hook_file_dest_path(&self, _name: &str) -> Option<PathBuf>

Relative destination for an opaque file-mode fragment.

Source

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.

Source

fn mcp_config_file_names(&self) -> &'static [&'static str]

Config files mutated by MCP entries.

Source

fn hook_config_file_names(&self) -> &'static [&'static str]

Config files mutated by merge-mode hook entries.

Source

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.

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_owned_hook_entries( &self, operation: RemovalOperation<'_>, project_root: &Path, _diag: &mut DiagnosticCollector, ) -> RemovalReport

Remove hook entries recorded in the previous lock by structural equality.

Source

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

Implementors§