1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
extern crate reqwest;
extern crate serde_json;
extern crate serde;
#[macro_use] extern crate serde_derive;
extern crate failure;
extern crate base64;
mod v0;
mod ipns;
mod object;
pub mod pin;
pub mod pubsub;
mod version;
mod shutdown;
mod block;
pub struct IpfsApi {
url: url::Url,
client : reqwest::Client,
}
impl IpfsApi {
pub fn new(url: &str) -> Result<IpfsApi, url::ParseError> {
Ok(IpfsApi {
client: reqwest::Client::new(),
url: url::Url::parse(url)?,
})
}
fn get_url(&self) -> Result<reqwest::Url, url::ParseError> {
Ok(self.url.clone())
}
}