diff --git a/crates/maestro-protocol/src/client.rs b/crates/maestro-protocol/src/client.rs index 7d03e38..59e0eb7 100644 --- a/crates/maestro-protocol/src/client.rs +++ b/crates/maestro-protocol/src/client.rs @@ -16,7 +16,7 @@ use uuid::Uuid; use crate::routes::{self, UrlError}; use crate::{ ApiError, BranchInfo, CreateSessionRequest, DaemonInfo, DirListing, ErrorInfo, GitRoot, - Project, RecentDirs, Session, + Project, RecentDirs, RetainedWorktree, Session, }; /// Time budget for establishing a TCP connection to the daemon. @@ -148,6 +148,23 @@ impl DaemonClient { .await } + /// `GET /api/worktrees` (#80): every retained worktree with its in-the-way + /// breakdown as of this read. + pub async fn list_worktrees(&self) -> Result, ClientError> { + self.get(routes::WORKTREES, &[]).await + } + + /// `DELETE /api/worktrees/:id` (#86): reclaim one retained worktree. The + /// daemon removes the directory and drops the store entry; the branch is + /// never deleted. + pub async fn reclaim_worktree(&self, id: Uuid) -> Result<(), ClientError> { + let resp = self + .send(Method::DELETE, &routes::worktree(id), &[], None::<&()>) + .await?; + check(resp).await?; + Ok(()) + } + // -- plumbing ----------------------------------------------------------- async fn get(