radicle: Make `node::Link` copy and add `is_*`
This will allow us to replace `netservices::LinkDirection` with `radicle::node::Link` in a drop-in manner.
This commit is contained in:
parent
408d4f27e7
commit
b9759c5868
|
|
@ -723,7 +723,7 @@ impl Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Connection link direction.
|
/// Connection link direction.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||||
pub enum Link {
|
pub enum Link {
|
||||||
|
|
@ -733,6 +733,18 @@ pub enum Link {
|
||||||
Inbound,
|
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.
|
/// An established network connection with a peer.
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue