Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more ObjectStats fields #3

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ mod ipns;
mod object;
mod version;

#[derive(Clone, PartialEq, Hash, Debug)]
pub struct IpfsApi {
server: String,
port: u16
Expand Down
14 changes: 11 additions & 3 deletions src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ error_chain! {
#[derive(Deserialize, Debug, PartialEq, Hash)]
#[serde(rename_all="PascalCase")]
pub struct ObjectStats {
hash: String,
cumulative_size: u64
pub hash: String,
pub num_links: u64,
pub block_size: u64,
pub links_size: u64,
pub data_size: u64,
pub cumulative_size: u64
}

impl IpfsApi {
Expand All @@ -39,9 +43,13 @@ mod tests {
let stats = api.object_stats("QmWATWQ7fVPP2EFGu71UkfnqhYXDYH566qy47CnJDgvs8u").unwrap();
let desired = ObjectStats {
hash: "QmWATWQ7fVPP2EFGu71UkfnqhYXDYH566qy47CnJDgvs8u".to_string(),
num_links: 0,
block_size: 20,
links_size: 2,
data_size: 18,
cumulative_size: 20,
};

assert_eq!(stats, desired);
}
}
}
13 changes: 6 additions & 7 deletions src/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ error_chain! {
#[derive(Deserialize, Debug, PartialEq, Hash)]
#[serde(rename_all="PascalCase")]
pub struct PinAddResponse {
pins: Vec<String>,
progress: Option<u64>
pub pins: Vec<String>,
pub progress: Option<u64>
}

#[derive(Deserialize, Debug, PartialEq, Hash)]
#[serde(rename_all="PascalCase")]
pub struct PinRmResponse {
pins: Vec<String>
pub pins: Vec<String>
}

#[derive(Deserialize, Debug, PartialEq, Hash)]
pub struct PinType {
#[serde(rename = "Type")]
objtype: String,
pub objtype: String,
}

#[derive(Deserialize, Debug, PartialEq)]
#[serde(rename_all="PascalCase")]
pub struct PinList {
// keys: Vec<String>
keys: HashMap<String, PinType>
pub keys: HashMap<String, PinType>
}

impl IpfsApi {
Expand Down Expand Up @@ -82,7 +82,6 @@ impl IpfsApi {

#[cfg(test)]
mod tests {
use std::collections::HashMap;
use IpfsApi;
use super::*;

Expand Down Expand Up @@ -132,4 +131,4 @@ mod tests {
};
assert_eq!(resp.unwrap(), desired);
}
}
}
6 changes: 3 additions & 3 deletions src/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ struct JsonPubSubMessage {

#[derive(Debug)]
pub struct PubSubMessage {
data: Option<Vec<u8>>,
from: Option<Vec<u8>>,
seqno: Option<Vec<u8>>
pub data: Option<Vec<u8>>,
pub from: Option<Vec<u8>>,
pub seqno: Option<Vec<u8>>
}

impl PubSubMessage {
Expand Down
10 changes: 5 additions & 5 deletions src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ error_chain! {
#[derive(Deserialize, Debug)]
#[serde(rename_all="PascalCase")]
pub struct IpfsVersion {
version: String,
commit: String,
repo: String,
system: String,
golang: String
pub version: String,
pub commit: String,
pub repo: String,
pub system: String,
pub golang: String
}

impl IpfsApi {
Expand Down