corepc_client/client_sync/v17/
network.rs1#[macro_export]
14macro_rules! impl_client_v17__add_node {
15 () => {
16 impl Client {
17 pub fn add_node(&self, node: &str, command: AddNodeCommand) -> Result<()> {
18 match self.call("addnode", &[into_json(node)?, into_json(command)?]) {
19 Ok(serde_json::Value::Null) => Ok(()),
20 Ok(res) => Err(Error::Returned(res.to_string())),
21 Err(err) => Err(err.into()),
22 }
23 }
24 }
25 };
26}
27
28#[macro_export]
30macro_rules! impl_client_v17__clear_banned {
31 () => {
32 impl Client {
33 pub fn clear_banned(&self) -> Result<()> {
34 match self.call("clearbanned", &[]) {
35 Ok(serde_json::Value::Null) => Ok(()),
36 Ok(res) => Err(Error::Returned(res.to_string())),
37 Err(err) => Err(err.into()),
38 }
39 }
40 }
41 };
42}
43
44#[macro_export]
46macro_rules! impl_client_v17__disconnect_node {
47 () => {
48 impl Client {
49 pub fn disconnect_node(&self, address: &str) -> Result<()> {
50 match self.call("disconnectnode", &[into_json(address)?]) {
51 Ok(serde_json::Value::Null) => Ok(()),
52 Ok(res) => Err(Error::Returned(res.to_string())),
53 Err(err) => Err(err.into()),
54 }
55 }
56 }
57 };
58}
59
60#[macro_export]
62macro_rules! impl_client_v17__get_added_node_info {
63 () => {
64 impl Client {
65 pub fn get_added_node_info(&self) -> Result<GetAddedNodeInfo> {
66 self.call("getaddednodeinfo", &[])
67 }
68 }
69 };
70}
71
72#[macro_export]
74macro_rules! impl_client_v17__get_connection_count {
75 () => {
76 impl Client {
77 pub fn get_connection_count(&self) -> Result<GetConnectionCount> {
78 self.call("getconnectioncount", &[])
79 }
80 }
81 };
82}
83
84#[macro_export]
86macro_rules! impl_client_v17__get_net_totals {
87 () => {
88 impl Client {
89 pub fn get_net_totals(&self) -> Result<GetNetTotals> { self.call("getnettotals", &[]) }
90 }
91 };
92}
93
94#[macro_export]
96macro_rules! impl_client_v17__get_network_info {
97 () => {
98 impl Client {
99 pub fn server_version(&self) -> Result<usize> {
101 let info = self.get_network_info()?;
102 Ok(info.version)
103 }
104
105 pub fn get_network_info(&self) -> Result<GetNetworkInfo> {
106 self.call("getnetworkinfo", &[])
107 }
108 }
109 };
110}
111
112#[macro_export]
114macro_rules! impl_client_v17__get_peer_info {
115 () => {
116 impl Client {
117 pub fn get_peer_info(&self) -> Result<GetPeerInfo> { self.call("getpeerinfo", &[]) }
118 }
119 };
120}
121
122#[macro_export]
124macro_rules! impl_client_v17__list_banned {
125 () => {
126 impl Client {
127 pub fn list_banned(&self) -> Result<ListBanned> { self.call("listbanned", &[]) }
128 }
129 };
130}
131
132#[macro_export]
134macro_rules! impl_client_v17__ping {
135 () => {
136 impl Client {
137 pub fn ping(&self) -> Result<()> {
138 match self.call("ping", &[]) {
139 Ok(serde_json::Value::Null) => Ok(()),
140 Ok(res) => Err(Error::Returned(res.to_string())),
141 Err(err) => Err(err.into()),
142 }
143 }
144 }
145 };
146}
147
148#[macro_export]
150macro_rules! impl_client_v17__set_ban {
151 () => {
152 impl Client {
153 pub fn set_ban(&self, subnet: &str, command: SetBanCommand) -> Result<()> {
154 match self.call("setban", &[into_json(subnet)?, into_json(command)?]) {
155 Ok(serde_json::Value::Null) => Ok(()),
156 Ok(res) => Err(Error::Returned(res.to_string())),
157 Err(err) => Err(err.into()),
158 }
159 }
160 }
161 };
162}
163
164#[macro_export]
166macro_rules! impl_client_v17__set_network_active {
167 () => {
168 impl Client {
169 pub fn set_network_active(&self, state: bool) -> Result<SetNetworkActive> {
170 self.call("setnetworkactive", &[into_json(state)?])
171 }
172 }
173 };
174}