pub struct TargetManager { /* private fields */ }Expand description
Manager for loading and managing sync targets.
Supports both built-in targets (Antigravity, Claude, Codex, OpenCode) and dynamically loaded targets from shared libraries.
§Example
ⓘ
use mcp_sync::TargetManager;
let mut mgr = TargetManager::new();
// Load all built-in targets
mgr.load_builtin_all();
// Load a custom target from dylib
unsafe {
mgr.load_dynamic(Path::new("./my_target.dylib"))?;
}
// Sync all targets
for target in mgr.targets() {
target.sync_global(&canon, &opts)?;
}Implementations§
Source§impl TargetManager
impl TargetManager
Sourcepub fn with_builtins() -> Self
pub fn with_builtins() -> Self
Creates a target manager pre-loaded with all built-in targets.
Sourcepub fn load_builtin_all(&mut self)
pub fn load_builtin_all(&mut self)
Loads all built-in targets.
Sourcepub fn load_builtin(&mut self, name: &str) -> Result<()>
pub fn load_builtin(&mut self, name: &str) -> Result<()>
Loads a specific built-in target by name.
Sourcepub unsafe fn load_dynamic(&mut self, path: &Path) -> Result<()>
pub unsafe fn load_dynamic(&mut self, path: &Path) -> Result<()>
Loads a custom target from a dynamic library.
The library must export a create_target function:
ⓘ
#[unsafe(no_mangle)]
pub extern "C" fn create_target() -> *mut dyn Target {
Box::into_raw(Box::new(MyTarget::new()))
}§Safety
The caller must ensure the library is compatible and the
create_target function returns a valid Target pointer.
Sourcepub fn targets(&self) -> impl Iterator<Item = &dyn Target>
pub fn targets(&self) -> impl Iterator<Item = &dyn Target>
Returns an iterator over all loaded targets.
Sourcepub fn targets_mut(&mut self) -> impl Iterator<Item = &mut Box<dyn Target>>
pub fn targets_mut(&mut self) -> impl Iterator<Item = &mut Box<dyn Target>>
Returns a mutable iterator over all loaded targets.
Sourcepub fn sync_all_global(&self, canon: &Canon, opts: &SyncOptions) -> Result<()>
pub fn sync_all_global(&self, canon: &Canon, opts: &SyncOptions) -> Result<()>
Syncs all targets to their global configuration files.
Sourcepub fn sync_all_project(
&self,
project_root: &Path,
canon: &Canon,
opts: &SyncOptions,
) -> Result<()>
pub fn sync_all_project( &self, project_root: &Path, canon: &Canon, opts: &SyncOptions, ) -> Result<()>
Syncs all targets to their project configuration files.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TargetManager
impl !RefUnwindSafe for TargetManager
impl Send for TargetManager
impl Sync for TargetManager
impl Unpin for TargetManager
impl !UnwindSafe for TargetManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more