Skip to main content

nextcloud_users/capabilities/
core.rs

1use serde::{Deserialize, Serialize};
2
3use super::ServerStatus;
4use crate::wire::lossy_opt_u64;
5
6/// Core capabilities exposed by the server.
7#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize)]
8pub struct CoreCapabilities {
9    /// Recommended poll interval for client sync in seconds.
10    #[serde(
11        default,
12        alias = "pollinterval",
13        alias = "poll_interval",
14        deserialize_with = "lossy_opt_u64"
15    )]
16    pub poll_interval: Option<u64>,
17    /// Relative or absolute path to the WebDAV endpoint root (e.g. `"remote.php/webdav"`).
18    #[serde(default, alias = "webdav-root", alias = "webdav_root")]
19    pub webdav_root: Option<String>,
20    /// Server installation and runtime status.
21    #[serde(default)]
22    pub status: Option<ServerStatus>,
23}
24
25impl CoreCapabilities {
26    /// Recommended background polling interval in seconds.
27    pub const fn poll_interval(&self) -> Option<u64> {
28        self.poll_interval
29    }
30
31    /// Root WebDAV path advertised by the instance.
32    pub fn webdav_root(&self) -> Option<&str> {
33        self.webdav_root.as_deref()
34    }
35
36    /// Server operational status.
37    pub fn status(&self) -> Option<&ServerStatus> {
38        self.status.as_ref()
39    }
40}