Skip to content

Commit

Permalink
Updated pin_add() API slightly and added example.
Browse files Browse the repository at this point in the history
  • Loading branch information
icefoxen committed Dec 4, 2017
1 parent 251b04e commit 2f6025a
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions ipfs-api/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,15 +823,35 @@ impl IpfsClient {

/// Pins a new object.
///
/// Does not yet implement "progress" because reading it is kinda squirrelly.
/// The "recursive" option tells the server whether to
/// pin just the top-level object, or all sub-objects
/// it depends on. For most cases you want it to be `true`.
///
/// Does not yet implement the "progress" agument because
/// reading it is kinda squirrelly.
///
/// # Examples
///
/// ```no_run
/// # extern crate ipfs_api;
/// # extern crate tokio_core;
/// #
/// use ipfs_api::IpfsClient;
/// use tokio_core::reactor::Core;
///
/// # fn main() {
/// let mut core = Core::new().unwrap();
/// let client = IpfsClient::default(&core.handle());
/// let req = client.pin_add("QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ", true);
/// # }
/// ```
#[inline]
pub fn pin_add(
&self,
key: &str,
recursive: Option<bool>
recursive: bool
) -> AsyncResponse<response::PinLsResponse> {
self.request(&request::PinAdd { key, recursive, progress: false }, None)
self.request(&request::PinAdd { key, recursive: Some(recursive), progress: false }, None)
}

/// Returns a list of pinned objects in local storage.
Expand Down

0 comments on commit 2f6025a

Please sign in to comment.