Skip to main content

rsynko_manager/
intent.rs

1use crate::{FormatDiscoveryOp, RehearsalObservationOp};
2use alux_sdk::trait_algebra;
3use std::path::PathBuf;
4use std::time::Duration;
5
6/// Defines the first-order observation stream affecting one transfer.
7///
8/// A variant is a method: the reified stream is generated from this vocabulary rather than written
9/// out, so an interpreter states what an observation *means* and never restates the shape.
10#[trait_algebra(derive(Clone, Debug, PartialEq, Eq))]
11pub trait TransferObservation {
12    /// Observes whether the active interpreter can cooperatively pause retrieval.
13    fn pause_capability(&self, supported: bool);
14
15    /// Denotes that an interpreter started extraction.
16    fn started(&self);
17
18    /// Observes elapsed transfer time.
19    fn elapsed(&self, elapsed: Duration);
20
21    /// Observes incremental byte progress toward one intended final path.
22    fn progress(&self, destination: PathBuf, downloaded: u64, total: Option<u64>);
23
24    /// Observes terminal completion at a published path.
25    fn completed(&self, destination: PathBuf, bytes: u64);
26
27    /// Observes terminal failure before publication completed.
28    fn failed(&self, destination: PathBuf, message: String);
29
30    /// Denotes failure outside the resource-download program.
31    fn program_failed(&self, summary: String, detail: String);
32}
33
34/// Defines the first-order intent stream one manager interprets.
35///
36/// An intention is a method, so the reified stream is generated from this vocabulary rather than
37/// written out. An interpreter states what each intention *means* and never restates the shape.
38#[trait_algebra(derive(Clone, Debug, PartialEq, Eq))]
39pub trait ManagerIntent {
40    /// Represents one stable queue identity.
41    type Id;
42    /// Represents one submitted source.
43    type Source;
44    /// Represents one selectable format description.
45    type Format;
46    /// Represents one change a rehearsal states.
47    type Change;
48
49    /// Adds explicit source requests to the collection.
50    fn add_sources(&self, requests: Vec<Self::Source>);
51
52    /// Replaces the editor draft.
53    fn set_draft(&self, draft: String);
54
55    /// Inserts text at the active editor cursor.
56    fn insert_text(&self, text: String);
57
58    /// Replaces the output-file-name editor draft.
59    fn set_output_draft(&self, draft: String);
60
61    /// Replaces the input editor draft.
62    fn set_input_draft(&self, draft: String);
63
64    /// Supplies extracted identity and title observations.
65    fn source_metadata(&self, id: Self::Id, media_id: String, title: Option<String>);
66
67    /// Applies one format-discovery observation to a stable queue identity.
68    fn format_catalog(&self, id: Self::Id, event: FormatDiscoveryOp<Self::Format>);
69
70    /// Applies one rehearsal observation to a stable queue identity.
71    fn rehearsal(&self, id: Self::Id, event: RehearsalObservationOp<Self::Change>);
72
73    /// Applies one transfer observation to a stable queue identity.
74    fn transfer(&self, id: Self::Id, event: TransferObservationOp);
75
76    /// Opens the add-sources editor.
77    fn open_add_sources(&self);
78
79    /// Submits newline-separated sources from the editor draft.
80    fn submit_draft(&self);
81
82    /// Deletes the Unicode scalar before the active editor cursor.
83    fn delete_before_cursor(&self);
84
85    /// Deletes the Unicode scalar at the active editor cursor.
86    fn delete_at_cursor(&self);
87
88    /// Moves the active editor cursor left by one Unicode scalar.
89    fn move_cursor_left(&self);
90
91    /// Moves the active editor cursor right by one Unicode scalar.
92    fn move_cursor_right(&self);
93
94    /// Moves the active editor cursor to its logical line beginning.
95    fn move_cursor_home(&self);
96
97    /// Moves the active editor cursor to its logical line end.
98    fn move_cursor_end(&self);
99
100    /// Selects the preceding collection entry with wraparound.
101    fn select_previous(&self);
102
103    /// Selects the following collection entry with wraparound.
104    fn select_next(&self);
105
106    /// Expands details for the selected entry while preserving row focus.
107    fn open_selected(&self);
108
109    /// Selects the preceding visible details control.
110    fn select_previous_detail(&self);
111
112    /// Selects the following visible details control.
113    fn select_next_detail(&self);
114
115    /// Activates the selected control, or collapses details while the row has focus.
116    fn activate_detail(&self);
117
118    /// Opens the concrete-format selector for the selected editable entry.
119    fn open_formats(&self);
120
121    /// Opens output-file-name editing for the selected editable entry.
122    fn open_output(&self);
123
124    /// Opens input editing for the selected entry, while its input may still be changed.
125    fn open_input(&self);
126
127    /// Applies the input editor draft.
128    fn submit_input(&self);
129
130    /// Opens the report of what the selected request would do.
131    fn open_report(&self);
132
133    /// Turns the rehearsal mode of the selected request on or off.
134    fn toggle_dry_run(&self);
135
136    /// Applies the normalized output-file-name editor draft.
137    fn submit_output(&self);
138
139    /// Navigates to the parent page.
140    fn back(&self);
141
142    /// Applies the selected entry's currently valid space action.
143    fn apply_selected_space(&self);
144
145    /// Selects the preceding compatible format choice.
146    fn select_previous_format(&self);
147
148    /// Selects the following compatible format choice.
149    fn select_next_format(&self);
150
151    /// Duplicates the selected source as a fresh editable request.
152    fn duplicate_selected(&self);
153
154    /// Removes the selected entry.
155    fn remove_selected(&self);
156
157    /// Marks the selected failed entry as waiting with its fixed options.
158    fn restart_selected(&self);
159
160    /// Requests exit after active work reaches a safe boundary.
161    fn safe_exit_requested(&self);
162}
163
164/// Denotes the valid meaning of Space for one queue entry.
165#[derive(Clone, Copy, Debug, PartialEq, Eq)]
166pub enum SpaceAction {
167    /// Fixes and queues one ready request.
168    Start,
169    /// Queues one ready request to state what it would do instead of doing it.
170    Rehearse,
171    /// Pauses a cooperatively pausable active transfer.
172    Pause,
173    /// Resumes a paused transfer.
174    Resume,
175}
176
177/// Denotes one manager page independently of rendering mechanism.
178#[derive(Clone, Copy, Debug, PartialEq, Eq)]
179pub enum ManagerPage<Id> {
180    /// Denotes the queue collection and its list selector.
181    Collection,
182    /// Denotes the add-sources editor.
183    AddSources,
184    /// Denotes one queue identity expanded within the collection.
185    Details(Id),
186    /// Denotes format selection for one editable queue identity.
187    Formats(Id),
188    /// Denotes output-file-name editing for one editable queue identity.
189    Output(Id),
190    /// Denotes input editing for one queue identity whose input may still be changed.
191    Input(Id),
192    /// Denotes the record of what was observed about one queue identity.
193    Log(Id),
194    /// Denotes the report of what one queue identity would do.
195    Report(Id),
196    /// Denotes the command one queue identity would run, stated so it can be taken away.
197    Command(Id),
198}
199
200/// Identifies one visible, selectable control in expanded details.
201#[derive(Clone, Copy, Debug, PartialEq, Eq)]
202pub enum DetailControl {
203    /// Opens input editing.
204    Input,
205    /// Opens output-file-name editing.
206    Output,
207    /// Opens concrete-format selection.
208    Format,
209    /// Opens the command the request would run, stated whole.
210    Command,
211    /// Restarts one failed request with its fixed options.
212    Restart,
213    /// Duplicates the source into a fresh editable request.
214    Duplicate,
215    /// Turns the rehearsal mode on or off.
216    DryRun,
217    /// Opens the report of what the request would do.
218    Report,
219    /// Opens the record of what was observed about the request.
220    Log,
221    /// Deletes the queue entry.
222    Delete,
223}
224
225/// Denotes one breadcrumb segment.
226#[derive(Clone, Debug, PartialEq, Eq)]
227pub struct Breadcrumb {
228    /// Names the segment.
229    pub label: String,
230}