Skip to main content

purple_ssh/app/
update.rs

1/// Update availability state.
2///
3/// `hint` defaults to `""` via `#[derive(Default)]`. In practice `App::new()`
4/// always overwrites it with the detected install method, so the empty default
5/// is only visible when constructing `UpdateState` in isolation (e.g. tests).
6#[derive(Default)]
7pub struct UpdateState {
8    /// Available version string (None if up to date or unchecked).
9    pub available: Option<String>,
10    /// Update announcement headline.
11    pub headline: Option<String>,
12    /// Update hint string (install command suggestion).
13    pub hint: &'static str,
14}
15
16impl UpdateState {
17    /// Construct with the current install-method hint detected at runtime.
18    pub fn with_current_hint() -> Self {
19        Self {
20            hint: crate::update::update_hint(),
21            ..Self::default()
22        }
23    }
24}