Target

Trait Target 

Source
pub trait Target: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn global_path(&self) -> Result<PathBuf>;
    fn project_path(&self, project_root: &Path) -> PathBuf;
    fn sync(&self, path: &Path, canon: &Canon, opts: &SyncOptions) -> Result<()>;

    // Provided methods
    fn sync_global(&self, canon: &Canon, opts: &SyncOptions) -> Result<()> { ... }
    fn sync_project(
        &self,
        project_root: &Path,
        canon: &Canon,
        opts: &SyncOptions,
    ) -> Result<()> { ... }
}
Expand description

Trait for MCP configuration sync targets.

Each target (e.g., Antigravity, Claude) implements this trait to provide target-specific file paths and sync logic.

§Example

struct MyTarget;
 
impl Target for MyTarget {
    fn name(&self) -> &'static str { "my-target" }
    fn global_path(&self) -> Result<PathBuf> { Ok(home()?.join(".my-config.json")) }
    fn project_path(&self, root: &Path) -> PathBuf { root.join(".my-config.json") }
    fn sync(&self, path: &Path, canon: &Canon, opts: &SyncOptions) -> Result<()> {
        // Implementation
        Ok(())
    }
}

Required Methods§

Source

fn name(&self) -> &'static str

Returns the human-readable name of this target.

Source

fn global_path(&self) -> Result<PathBuf>

Returns the path to the global (user-level) configuration file.

Source

fn project_path(&self, project_root: &Path) -> PathBuf

Returns the path to the project-level configuration file.

Source

fn sync(&self, path: &Path, canon: &Canon, opts: &SyncOptions) -> Result<()>

Syncs the canonical configuration to the target file.

§Arguments
  • path - The target file path (global or project)
  • canon - The parsed canonical configuration
  • opts - Sync options (clean, dry_run, verbose)

Provided Methods§

Source

fn sync_global(&self, canon: &Canon, opts: &SyncOptions) -> Result<()>

Syncs to the global configuration file.

Source

fn sync_project( &self, project_root: &Path, canon: &Canon, opts: &SyncOptions, ) -> Result<()>

Syncs to the project configuration file.

Implementors§