Skip to main content

workyard_application/actions/recover/
input.rs

1use schemars::JsonSchema;
2use serde::Deserialize;
3use trine::NativePath;
4
5/// Select a task or the workspace and specify the authorized recovery direction.
6#[derive(Default, Deserialize, JsonSchema)]
7#[serde(deny_unknown_fields)]
8pub struct RecoverInput {
9	/// Resume a named task operation. Omit for workspace location recovery.
10	pub task: Option<String>,
11	/// Use the verified worktrees in this workspace when multiple copies exist.
12	#[serde(default)]
13	pub activate_here: bool,
14	/// Explicit workspace directory containing .workyard.
15	pub workspace: Option<NativePath>,
16	/// Resume in the restoration direction.
17	#[serde(default)]
18	pub undo: bool,
19	/// Accept routine confirmation.
20	#[serde(default)]
21	pub yes: bool,
22	/// Authorize the disclosed discard and accept routine confirmation.
23	#[serde(default)]
24	pub force: bool,
25}
26
27#[derive(Deserialize, JsonSchema)]
28#[serde(deny_unknown_fields)]
29pub(crate) struct NamedParticipantRecovery {
30	/// Task whose creation, checkout or participant additions and renames should be continued.
31	pub task: String,
32	/// Workspace directory containing .workyard. Defaults to ancestor discovery.
33	pub workspace: Option<NativePath>,
34}
35
36#[derive(Deserialize, JsonSchema)]
37#[serde(from = "RecoverInput")]
38#[schemars(rename = "RecoverInput")]
39pub(crate) enum RecoveryRequest {
40	General(RecoverInput),
41	Participants(NamedParticipantRecovery),
42}
43
44impl From<RecoverInput> for RecoveryRequest {
45	fn from(input: RecoverInput) -> Self {
46		Self::General(input)
47	}
48}