Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
radicle: Make `node::Link` copy and add `is_*`
Lorenz Leutgeb committed 10 months ago
commit 6aecac5744b076cb2f06987281f42b907a6d4a69
parent fb8681f5bc5460a7970f023d61b272d0a1474711
1 file changed +13 -1
modified crates/radicle/src/node.rs
@@ -723,7 +723,7 @@ impl Command {
}

/// Connection link direction.
-
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
pub enum Link {
@@ -733,6 +733,18 @@ pub enum Link {
    Inbound,
}

+
impl Link {
+
    /// Check if this is an outbound link.
+
    pub fn is_outbound(&self) -> bool {
+
        matches!(self, Self::Outbound)
+
    }
+

+
    /// Check if this is an inbound link.
+
    pub fn is_inbound(&self) -> bool {
+
        matches!(self, Self::Inbound)
+
    }
+
}
+

/// An established network connection with a peer.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]