Skip to main content

nextcloud_users/capabilities/
status.rs

1use serde::{Deserialize, Serialize};
2
3use crate::wire::lossy_bool;
4
5/// Operational status and runtime state of the Nextcloud instance.
6#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)]
7pub struct ServerStatus {
8    /// Whether Nextcloud is installed and configured.
9    #[serde(default, deserialize_with = "lossy_bool")]
10    pub installed: bool,
11    /// Whether the instance is in maintenance mode.
12    #[serde(default, deserialize_with = "lossy_bool")]
13    pub maintenance: bool,
14    /// Whether the database requires a pending migration or upgrade.
15    #[serde(
16        default,
17        alias = "needsDbUpgrade",
18        alias = "needs_db_upgrade",
19        deserialize_with = "lossy_bool"
20    )]
21    pub needs_db_upgrade: bool,
22    /// Precise version string (e.g. `"30.0.4.1"`).
23    #[serde(default)]
24    pub version: Option<String>,
25    /// Human-readable version string (e.g. `"30.0.4"`).
26    #[serde(default, alias = "versionstring", alias = "version_string")]
27    pub version_string: Option<String>,
28    /// Server edition (e.g. `"Community"`).
29    #[serde(default)]
30    pub edition: Option<String>,
31    /// Product branding name (e.g. `"Nextcloud"`).
32    #[serde(default, alias = "productname", alias = "product_name")]
33    pub product_name: Option<String>,
34}
35
36impl ServerStatus {
37    /// Whether the instance is installed and operational.
38    pub const fn is_installed(&self) -> bool {
39        self.installed
40    }
41
42    /// Whether maintenance mode is enabled.
43    pub const fn is_maintenance(&self) -> bool {
44        self.maintenance
45    }
46
47    /// Whether the instance is awaiting a database upgrade.
48    pub const fn needs_db_upgrade(&self) -> bool {
49        self.needs_db_upgrade
50    }
51
52    /// Precise version identifier.
53    pub fn version(&self) -> Option<&str> {
54        self.version.as_deref()
55    }
56
57    /// Human-readable version string.
58    pub fn version_string(&self) -> Option<&str> {
59        self.version_string.as_deref()
60    }
61
62    /// Server edition name.
63    pub fn edition(&self) -> Option<&str> {
64        self.edition.as_deref()
65    }
66
67    /// Product brand name.
68    pub fn product_name(&self) -> Option<&str> {
69        self.product_name.as_deref()
70    }
71}