pub struct SymlinkManager {
pub tracking: SymlinkTracking,
/* private fields */
}Expand description
Manages symlinks for dotfile profiles
Fields§
§tracking: SymlinkTrackingCurrent tracking data
Implementations§
Source§impl SymlinkManager
impl SymlinkManager
Sourcepub fn new_with_backup(repo_path: PathBuf, backup_enabled: bool) -> Result<Self>
pub fn new_with_backup(repo_path: PathBuf, backup_enabled: bool) -> Result<Self>
Create a new SymlinkManager with backup settings
Sourcepub fn new_with_config_dir(
repo_path: PathBuf,
backup_enabled: bool,
config_dir: PathBuf,
) -> Result<Self>
pub fn new_with_config_dir( repo_path: PathBuf, backup_enabled: bool, config_dir: PathBuf, ) -> Result<Self>
Create a new SymlinkManager with a custom config directory.
This is primarily used for testing to avoid polluting the real user’s config directory with test data.
Sourcepub fn activate_profile(
&mut self,
profile_name: &str,
files: &[String],
) -> Result<Vec<SymlinkOperation>>
pub fn activate_profile( &mut self, profile_name: &str, files: &[String], ) -> Result<Vec<SymlinkOperation>>
Activate a profile by creating all its symlinks
Sourcepub fn deactivate_profile(
&mut self,
profile_name: &str,
) -> Result<Vec<SymlinkOperation>>
pub fn deactivate_profile( &mut self, profile_name: &str, ) -> Result<Vec<SymlinkOperation>>
Deactivate a profile by removing its symlinks
Sourcepub fn deactivate_profile_with_restore(
&mut self,
_profile_name: &str,
restore_files: bool,
) -> Result<Vec<SymlinkOperation>>
pub fn deactivate_profile_with_restore( &mut self, _profile_name: &str, restore_files: bool, ) -> Result<Vec<SymlinkOperation>>
Deactivate all symlinks, optionally restoring original files.
This deactivates the ENTIRE app - all profile symlinks AND common file symlinks. Useful for temporarily disabling dotstate or as a pre-uninstall step.
When restore_files is true, each symlink is replaced with a copy of the file
from the repository, making it appear as if dotstate was never installed.
Sourcepub fn switch_profile(
&mut self,
from: &str,
to: &str,
to_files: &[String],
) -> Result<SwitchReport>
pub fn switch_profile( &mut self, from: &str, to: &str, to_files: &[String], ) -> Result<SwitchReport>
Switch from one profile to another
Sourcepub fn preview_switch(
&self,
from: &str,
to: &str,
to_files: &[String],
) -> Result<SwitchPreview>
pub fn preview_switch( &self, from: &str, to: &str, to_files: &[String], ) -> Result<SwitchPreview>
Preview what would happen during a switch (dry run)
Sourcepub fn save_tracking(&self) -> Result<()>
pub fn save_tracking(&self) -> Result<()>
Save tracking data to disk
Sourcepub fn get_active_profile(&self) -> Option<&str>
pub fn get_active_profile(&self) -> Option<&str>
Get the currently active profile name Get the currently active profile name
Sourcepub fn get_tracked_symlinks(&self) -> &[TrackedSymlink]
pub fn get_tracked_symlinks(&self) -> &[TrackedSymlink]
Get all tracked symlinks Get all tracked symlinks
Sourcepub fn rename_profile(
&mut self,
old_name: &str,
new_name: &str,
) -> Result<Vec<SymlinkOperation>>
pub fn rename_profile( &mut self, old_name: &str, new_name: &str, ) -> Result<Vec<SymlinkOperation>>
Rename a profile and update all associated symlinks This updates the source paths in the tracking file and recreates symlinks to point to the new profile folder location
Sourcepub fn add_symlink_to_profile(
&mut self,
profile_name: &str,
relative_path: &str,
) -> Result<SymlinkOperation>
pub fn add_symlink_to_profile( &mut self, profile_name: &str, relative_path: &str, ) -> Result<SymlinkOperation>
Add a single symlink to an existing profile.
This is more efficient than calling activate_profile with a single file, as it doesn’t need to iterate or create unnecessary data structures.
§Arguments
profile_name- Name of the profilerelative_path- Path relative to home directory (e.g., “.zshrc”)
§Returns
The symlink operation result
Sourcepub fn ensure_profile_symlinks(
&mut self,
profile_name: &str,
files: &[String],
) -> Result<(usize, usize, Vec<String>)>
pub fn ensure_profile_symlinks( &mut self, profile_name: &str, files: &[String], ) -> Result<(usize, usize, Vec<String>)>
Ensure all files in a profile have their symlinks created.
This is an efficient “reconciliation” method that only creates symlinks for files that are missing them. It’s perfect for after pulling changes from remote, where new files may have been added but their symlinks don’t exist locally yet.
Unlike activate_profile, this does NOT remove any existing symlinks - it only
adds missing ones.
§Arguments
profile_name- Name of the profilefiles- List of files that should have symlinks (relative paths)
§Returns
A tuple of (created_count, skipped_count, errors)
Sourcepub fn remove_symlink_from_tracking(
&mut self,
profile_name: &str,
relative_path: &str,
) -> Result<()>
pub fn remove_symlink_from_tracking( &mut self, profile_name: &str, relative_path: &str, ) -> Result<()>
Remove a specific symlink from tracking without affecting other symlinks.
This is a surgical operation that only updates the tracking data for a single file, unlike deactivate_profile which removes all symlinks for a profile.
§Arguments
profile_name- Name of the profilerelative_path- Path relative to home directory (e.g., “.zshrc”)
§Returns
Result indicating success or failure
Sourcepub fn add_common_symlink(
&mut self,
relative_path: &str,
) -> Result<SymlinkOperation>
pub fn add_common_symlink( &mut self, relative_path: &str, ) -> Result<SymlinkOperation>
Add a symlink for a common file (shared across all profiles).
Common files are stored in the “common” folder at the repository root and are symlinked regardless of which profile is active.
§Arguments
relative_path- Path relative to home directory (e.g., “.gitconfig”)
§Returns
The symlink operation result
Sourcepub fn remove_common_symlink(
&mut self,
relative_path: &str,
) -> Result<SymlinkOperation>
pub fn remove_common_symlink( &mut self, relative_path: &str, ) -> Result<SymlinkOperation>
Sourcepub fn remove_common_symlink_from_tracking(
&mut self,
relative_path: &str,
) -> Result<()>
pub fn remove_common_symlink_from_tracking( &mut self, relative_path: &str, ) -> Result<()>
Remove a common symlink from tracking only (without touching the actual symlink).
§Arguments
relative_path- Path relative to home directory
Sourcepub fn ensure_common_symlinks(
&mut self,
files: &[String],
) -> Result<(usize, usize, Vec<String>)>
pub fn ensure_common_symlinks( &mut self, files: &[String], ) -> Result<(usize, usize, Vec<String>)>
Sourcepub fn activate_common_files(
&mut self,
files: &[String],
) -> Result<Vec<SymlinkOperation>>
pub fn activate_common_files( &mut self, files: &[String], ) -> Result<Vec<SymlinkOperation>>
Auto Trait Implementations§
impl Freeze for SymlinkManager
impl RefUnwindSafe for SymlinkManager
impl Send for SymlinkManager
impl Sync for SymlinkManager
impl Unpin for SymlinkManager
impl UnwindSafe for SymlinkManager
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more