pub struct Client { /* private fields */ }
Expand description
A handle to a remote JSONRPC server
Implementations§
Source§impl Client
impl Client
Sourcepub fn new<P: AsRef<Path>>(sockpath: P) -> Client
pub fn new<P: AsRef<Path>>(sockpath: P) -> Client
Creates a new client
Examples found in repository?
examples/lowlevel_1.rs (line 10)
7fn main() {
8 let sock = env::home_dir().unwrap().join(".lightning/lightning-rpc");
9 println!("Using socket {}", sock.display());
10 let client = client::Client::new(&sock);
11 let method = "getinfo";
12 let params = requests::GetInfo {};
13 match client
14 .send_request(method, params)
15 .and_then(|res: clightningrpc::Response<responses::GetInfo>| res.into_result())
16 {
17 Ok(d) => {
18 println!("Ok! {:?}", d);
19 }
20 Err(e) => {
21 println!("Error! {}", e);
22 }
23 }
24}
More examples
examples/lowlevel_2.rs (line 11)
8fn main() {
9 let sock = env::home_dir().unwrap().join(".lightning/lightning-rpc");
10 println!("Using socket {}", sock.display());
11 let client = client::Client::new(&sock);
12 for style in &["perkb", "perkw"] {
13 let method = "feerates";
14 let params = requests::FeeRates {
15 style: style,
16 };
17
18 match client
19 .send_request(method, params)
20 .and_then(|res: clightningrpc::Response<responses::FeeRates>| res.into_result())
21 {
22 Ok(d) => {
23 println!("Ok! {:?}", d);
24 }
25 Err(e) => {
26 println!("Error! {}", e);
27 }
28 }
29 }
30}
Sourcepub fn set_timeout(&mut self, timeout: Option<Duration>)
pub fn set_timeout(&mut self, timeout: Option<Duration>)
Set an optional timeout for requests
Sourcepub fn send_request<S: Serialize, D: DeserializeOwned>(
&self,
method: &str,
params: S,
) -> Result<Response<D>, Error>
pub fn send_request<S: Serialize, D: DeserializeOwned>( &self, method: &str, params: S, ) -> Result<Response<D>, Error>
Sends a request to a client
Examples found in repository?
examples/lowlevel_1.rs (line 14)
7fn main() {
8 let sock = env::home_dir().unwrap().join(".lightning/lightning-rpc");
9 println!("Using socket {}", sock.display());
10 let client = client::Client::new(&sock);
11 let method = "getinfo";
12 let params = requests::GetInfo {};
13 match client
14 .send_request(method, params)
15 .and_then(|res: clightningrpc::Response<responses::GetInfo>| res.into_result())
16 {
17 Ok(d) => {
18 println!("Ok! {:?}", d);
19 }
20 Err(e) => {
21 println!("Error! {}", e);
22 }
23 }
24}
More examples
examples/lowlevel_2.rs (line 19)
8fn main() {
9 let sock = env::home_dir().unwrap().join(".lightning/lightning-rpc");
10 println!("Using socket {}", sock.display());
11 let client = client::Client::new(&sock);
12 for style in &["perkb", "perkw"] {
13 let method = "feerates";
14 let params = requests::FeeRates {
15 style: style,
16 };
17
18 match client
19 .send_request(method, params)
20 .and_then(|res: clightningrpc::Response<responses::FeeRates>| res.into_result())
21 {
22 Ok(d) => {
23 println!("Ok! {:?}", d);
24 }
25 Err(e) => {
26 println!("Error! {}", e);
27 }
28 }
29 }
30}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnwindSafe for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more