diff options
author | Ferris Tseng <ferristseng@fastmail.fm> | 2017-10-25 22:27:14 -0400 |
---|---|---|
committer | Ferris Tseng <ferristseng@fastmail.fm> | 2017-10-25 22:27:14 -0400 |
commit | 66ba58cb19682447c24538054dcf6cfeb49f00b6 (patch) | |
tree | f8995e3b27073cab6ea450c5801509ae24fcf8b9 | |
parent | aab991555d761a2517acde993db342a2368853cd (diff) |
add dns request
-rw-r--r-- | ipfs-api/src/client.rs | 8 | ||||
-rw-r--r-- | ipfs-api/src/request/dns.rs | 17 | ||||
-rw-r--r-- | ipfs-api/src/request/mod.rs | 2 | ||||
-rw-r--r-- | ipfs-api/src/response/dns.rs | 2 |
4 files changed, 27 insertions, 2 deletions
diff --git a/ipfs-api/src/client.rs b/ipfs-api/src/client.rs index 101fcfe..b98a048 100644 --- a/ipfs-api/src/client.rs +++ b/ipfs-api/src/client.rs @@ -98,7 +98,6 @@ impl IpfsClient { where for<'de> Res: 'static + Deserialize<'de>, { - println!("received '{}'", String::from_utf8_lossy(&chunk)); match status { StatusCode::Ok => serde_json::from_slice(&chunk).map_err(From::from), _ => Err(Self::build_error_from_body(chunk)), @@ -455,6 +454,13 @@ impl IpfsClient { self.request_string(&request::DiagSys) } + /// Resolve DNS link. + /// + #[inline] + pub fn dns(&self, link: &str, recursive: bool) -> AsyncResponse<response::DnsResponse> { + self.request(&request::Dns { link, recursive }) + } + /// List the contents of an Ipfs multihash. /// #[inline] diff --git a/ipfs-api/src/request/dns.rs b/ipfs-api/src/request/dns.rs new file mode 100644 index 0000000..7aa869b --- /dev/null +++ b/ipfs-api/src/request/dns.rs @@ -0,0 +1,17 @@ +use request::ApiRequest; + + +#[derive(Serialize)] +pub struct Dns<'a> { + #[serde(rename = "arg")] + pub link: &'a str, + + pub recursive: bool, +} + +impl<'a> ApiRequest for Dns<'a> { + #[inline] + fn path() -> &'static str { + "/dns" + } +} diff --git a/ipfs-api/src/request/mod.rs b/ipfs-api/src/request/mod.rs index 959d155..8edf732 100644 --- a/ipfs-api/src/request/mod.rs +++ b/ipfs-api/src/request/mod.rs @@ -8,6 +8,7 @@ pub use self::config::*; pub use self::dag::*; pub use self::dht::*; pub use self::diag::*; +pub use self::dns::*; pub use self::ls::*; pub use self::object::*; pub use self::pin::*; @@ -63,6 +64,7 @@ mod config; mod dag; mod dht; mod diag; +mod dns; mod ls; mod object; mod pin; diff --git a/ipfs-api/src/response/dns.rs b/ipfs-api/src/response/dns.rs index 57abdf2..ebe0fc8 100644 --- a/ipfs-api/src/response/dns.rs +++ b/ipfs-api/src/response/dns.rs @@ -1,4 +1,4 @@ -#[derive(Deserialize)] +#[derive(Debug, Deserialize)] #[serde(rename_all = "PascalCase")] pub struct DnsResponse { pub path: String, |