syncthing_types/system/
connections.rs1use crate::system::Statistics;
2use crate::{DeviceID, Timestamp};
3use serde::{Deserialize, Serialize};
4use std::collections::HashMap;
5
6#[non_exhaustive]
7#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
8#[serde(rename_all = "camelCase")]
9pub struct TotalConnectionsStatistic {
10 pub at: Timestamp,
11 pub in_bytes_total: u64,
12 pub out_bytes_total: u64,
13}
14
15#[non_exhaustive]
16#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
17#[serde(rename_all = "camelCase")]
18pub struct ConnectionInfo {
19 pub address: String,
20 #[serde(rename = "type")]
21 pub connection_type: String,
22 pub is_local: bool,
23 pub crypto: String,
24
25 #[serde(flatten)]
26 pub statistics: Statistics,
27}
28
29#[non_exhaustive]
30#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
31#[serde(rename_all = "camelCase")]
32pub struct ConnectionStats {
33 pub connected: bool,
34 pub paused: bool,
35 pub client_version: String,
36
37 pub primary: Option<ConnectionInfo>,
38 #[serde(default)]
39 pub secondary: Vec<ConnectionInfo>,
40
41 #[serde(flatten)]
43 pub statistics: Statistics,
44}
45
46#[non_exhaustive]
47#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
48pub struct Connections {
49 pub total: TotalConnectionsStatistic,
50 pub connections: HashMap<DeviceID, ConnectionStats>,
51}