Skip to main content

wekan_cli/command_result/
self_update.rs

1use serde::Serialize;
2
3#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize)]
4#[serde(rename_all = "snake_case")]
5pub enum InstallationMethod {
6    Release,
7    Cargo,
8    Unknown,
9}
10
11#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize)]
12#[serde(rename_all = "snake_case")]
13pub enum SelfUpdateStatus {
14    UpToDate,
15    Available,
16    Updated,
17}
18
19#[derive(Debug, Eq, PartialEq, Serialize)]
20pub struct SelfUpdateSuccess {
21    /// Version running when the command started, including after replacement.
22    pub current_version: String,
23    pub latest_version: String,
24    pub status: SelfUpdateStatus,
25    pub installation_method: InstallationMethod,
26    pub release_url: String,
27}
28
29/// Startup update checks can continue, display a notice, or stop after installing.
30#[derive(Debug)]
31pub(crate) enum StartupUpdateOutcome {
32    Continue,
33    Notice(SelfUpdateSuccess),
34    Updated,
35}
36
37impl StartupUpdateOutcome {
38    pub const fn should_exit(&self) -> bool {
39        matches!(self, Self::Updated)
40    }
41}