pub struct SyncProcess<Phase> {
pub repo_path: PathBuf,
pub phase: Phase,
}Expand description
Sync process with typestate-enforced phases.
Use SyncProcess::new() to start, then chain transitions:
ⓘ
let synced = SyncProcess::new(repo_path)
.fetch(&repo)?
.merge(&local_state, stamp)?
.commit(&repo)?
.push(&repo)?;Fields§
§repo_path: PathBuf§phase: PhaseImplementations§
Source§impl SyncProcess<Idle>
impl SyncProcess<Idle>
Sourcepub fn fetch(self, repo: &Repository) -> Result<SyncProcess<Fetched>, SyncError>
pub fn fetch(self, repo: &Repository) -> Result<SyncProcess<Fetched>, SyncError>
Fetch from remote, transition to Fetched phase.
If no remote ref exists, creates an empty initial state.
Sourcepub fn fetch_best_effort(
self,
repo: &Repository,
) -> Result<SyncProcess<Fetched>, SyncError>
pub fn fetch_best_effort( self, repo: &Repository, ) -> Result<SyncProcess<Fetched>, SyncError>
Best-effort fetch (allows offline/local-only operation).
Source§impl SyncProcess<Fetched>
impl SyncProcess<Fetched>
Sourcepub fn merge(
self,
local_state: &CanonicalState,
resolution_stamp: Stamp,
) -> Result<SyncProcess<Merged>, SyncError>
pub fn merge( self, local_state: &CanonicalState, resolution_stamp: Stamp, ) -> Result<SyncProcess<Merged>, SyncError>
Merge local state with remote, transition to Merged phase.
Handles:
- ID collisions (detects and resolves)
- CRDT pairwise merge (no base needed)
- Resurrection rule (bead beats tombstone if newer)
Source§impl SyncProcess<Merged>
impl SyncProcess<Merged>
Sourcepub fn commit(
self,
repo: &Repository,
) -> Result<SyncProcess<Committed>, SyncError>
pub fn commit( self, repo: &Repository, ) -> Result<SyncProcess<Committed>, SyncError>
Commit the merged state, transition to Committed phase.
Creates a commit with:
- Single parent (remote HEAD) - keeps history linear
- Meaningful commit message based on diff
Source§impl SyncProcess<Committed>
impl SyncProcess<Committed>
Sourcepub fn push(self, repo: &Repository) -> Result<CanonicalState, SyncError>
pub fn push(self, repo: &Repository) -> Result<CanonicalState, SyncError>
Push to remote, completing the sync.
Returns the synced state on success. Returns NonFastForward error if remote moved - caller should retry. If no remote is configured, returns success (local-only repo).
Sourcepub fn commit_oid(&self) -> Oid
pub fn commit_oid(&self) -> Oid
Get the commit oid.
Sourcepub fn into_state(self) -> CanonicalState
pub fn into_state(self) -> CanonicalState
Get the synced state without pushing.
Used when push isn’t needed (e.g., local-only testing).
Auto Trait Implementations§
impl<Phase> Freeze for SyncProcess<Phase>where
Phase: Freeze,
impl<Phase> RefUnwindSafe for SyncProcess<Phase>where
Phase: RefUnwindSafe,
impl<Phase> Send for SyncProcess<Phase>where
Phase: Send,
impl<Phase> Sync for SyncProcess<Phase>where
Phase: Sync,
impl<Phase> Unpin for SyncProcess<Phase>where
Phase: Unpin,
impl<Phase> UnsafeUnpin for SyncProcess<Phase>where
Phase: UnsafeUnpin,
impl<Phase> UnwindSafe for SyncProcess<Phase>where
Phase: UnwindSafe,
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