winbrew_app\operations\update/types.rs
1use serde::Deserialize;
2
3/// Data transfer objects for catalog update selection and download planning.
4#[derive(Debug, Clone, Deserialize)]
5pub(super) struct CatalogUpdateResponse {
6 /// The update strategy selected by the API.
7 pub mode: CatalogUpdateMode,
8 /// The catalog hash the API considers current for the local client.
9 pub current: String,
10 /// The hash the refreshed catalog should end up with.
11 pub target: String,
12 /// The full snapshot URL when the API returns a full snapshot plan.
13 pub snapshot: Option<String>,
14 /// Ordered patch URLs when the API returns a patch plan.
15 #[serde(default)]
16 pub patches: Vec<String>,
17}
18
19/// The mode returned by the catalog update API.
20#[derive(Debug, Clone, Copy, Deserialize, PartialEq, Eq)]
21#[serde(rename_all = "lowercase")]
22pub(super) enum CatalogUpdateMode {
23 /// The catalog is already up to date.
24 Current,
25 /// Download the full snapshot and rebuild local state.
26 Full,
27 /// Apply incremental SQL patches to the existing catalog.
28 Patch,
29}
30
31/// The internal plan used by the refresh workflow after API selection.
32#[derive(Debug, Clone)]
33pub(super) enum CatalogDownloadPlan {
34 /// No refresh work is needed because the hashes already match.
35 Current {
36 /// The hash reported as current by the API.
37 current_hash: String,
38 /// The hash the API expects after refresh.
39 target_hash: String,
40 },
41 /// Download a complete snapshot and its metadata.
42 Full {
43 /// URL for the compressed catalog snapshot.
44 catalog_url: String,
45 /// URL for the matching metadata JSON.
46 metadata_url: String,
47 /// Expected hash of the downloaded catalog snapshot.
48 expected_hash: Option<String>,
49 },
50 /// Apply one or more ordered SQL patch files.
51 Patch {
52 /// Ordered patch URLs to apply.
53 patch_urls: Vec<String>,
54 /// Expected hash after all patches are applied.
55 expected_hash: String,
56 },
57}