workyard_core/ports/
amendment.rs1use crate::{
2 AmendRequest, Control, Participant, Problem, RecoveryGit, RecoveryState, Repository, Task,
3};
4use std::{future::Future, path::Path};
5
6pub struct Relationship {
8 pub participant: Participant,
10 pub needs_repair: bool,
12}
13
14pub trait AmendGit: RecoveryGit + crate::RemovalGit + crate::ObservationGit {
16 fn relationship(
18 &self,
19 repository: &Repository,
20 participant: &Participant,
21 control: &Control,
22 ) -> impl Future<Output = Result<Relationship, Problem>> + Send;
23
24 fn repair(
26 &self,
27 repository: &Repository,
28 participant: &Participant,
29 control: &Control,
30 ) -> impl Future<Output = Result<(), Problem>> + Send;
31
32 fn move_worktree(
34 &self,
35 repository: &Repository,
36 participant: &Participant,
37 destination: &Path,
38 control: &Control,
39 ) -> impl Future<Output = Result<(), Problem>> + Send;
40}
41
42pub trait AmendState: RecoveryState {
44 type Checkpoint: Send;
46 fn staging_available(&self, path: &Path) -> Result<bool, Problem>;
48
49 fn same_destination(&self, left: &Path, right: &Path) -> Result<bool, Problem>;
51
52 fn begin_amend(
54 &self,
55 guard: &Self::Admission,
56 task: &Task,
57 request: &AmendRequest,
58 targets: &[crate::RemovalTarget],
59 ) -> Result<Self::Checkpoint, Problem>;
60
61 fn removal_targets(
63 &self,
64 guard: &Self::Admission,
65 ) -> Result<Vec<crate::RemovalTarget>, Problem>;
66
67 fn settle_unlink(
69 &self,
70 guard: &Self::Admission,
71 task: &Task,
72 target: &crate::RemovalTarget,
73 ) -> Result<(), Problem>;
74
75 fn unchanged_amend(
77 &self,
78 guard: &Self::Admission,
79 checkpoint: Self::Checkpoint,
80 ) -> Result<(), Problem>;
81
82 fn amend_request(&self, guard: &Self::Admission) -> Result<Option<AmendRequest>, Problem>;
84}