kaspa_wrpc_client/
node.rs

1//! Node connection endpoint as provided by the [`Resolver`].
2
3use crate::imports::*;
4
5///
6/// Data structure representing a Node connection endpoint
7/// as provided by the {@link Resolver}.
8///
9/// @category Node RPC
10///
11#[derive(Clone, Debug, Serialize, Deserialize)]
12#[wasm_bindgen(inspectable)]
13pub struct NodeDescriptor {
14    /// The unique identifier of the node.
15    #[wasm_bindgen(getter_with_clone)]
16    pub uid: String,
17    /// The URL of the node WebSocket (wRPC URL).
18    #[wasm_bindgen(getter_with_clone)]
19    pub url: String,
20}
21
22impl Eq for NodeDescriptor {}
23
24impl PartialEq for NodeDescriptor {
25    fn eq(&self, other: &Self) -> bool {
26        self.url == other.url
27    }
28}
29
30impl std::fmt::Display for NodeDescriptor {
31    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32        write!(f, "{}", self.url)
33    }
34}
35
36impl NodeDescriptor {
37    pub fn url(&self) -> String {
38        self.url.clone()
39    }
40}