reactive_graph_remotes_model/
instance_info.rs

1use crate::InstanceAddress;
2use chrono::DateTime;
3use chrono::Utc;
4use serde::Deserialize;
5use serde::Serialize;
6
7#[allow(clippy::derived_hash_with_manual_eq)]
8#[derive(Clone, Debug, Eq, Hash, Deserialize, Serialize)]
9#[serde(rename_all = "camelCase")]
10pub struct InstanceInfo {
11    /// The name of the instance.
12    pub name: String,
13
14    /// A description text about the instance.
15    pub description: String,
16
17    /// The instance address.
18    #[serde(flatten)]
19    pub address: InstanceAddress,
20
21    /// The version of the runtime (version field in Cargo.toml).
22    pub version: String,
23
24    /// The git commit.
25    pub git_commit: String,
26
27    /// The git tag.
28    pub git_tag: String,
29
30    /// The rust compiler channel.
31    pub rustc_channel: String,
32
33    /// The rust compiler version.
34    pub rustc_version: String,
35
36    /// The plugin api version.
37    pub plugin_api_version: String,
38
39    /// When the remote instance was last seen.
40    pub last_seen: DateTime<Utc>,
41}
42
43impl InstanceInfo {
44    pub fn address(&self) -> InstanceAddress {
45        self.address.clone()
46    }
47}
48
49// An InstanceInfo is equal if the InstanceAddress is equal
50impl PartialEq for InstanceInfo {
51    fn eq(&self, other: &Self) -> bool {
52        self.address == other.address
53    }
54}
55
56impl PartialEq<InstanceAddress> for InstanceInfo {
57    fn eq(&self, other: &InstanceAddress) -> bool {
58        &self.address == other
59    }
60}
61
62impl From<InstanceInfo> for InstanceAddress {
63    fn from(instance_info: InstanceInfo) -> Self {
64        instance_info.address.clone()
65    }
66}