pub struct IpfsApi { /* private fields */ }
Implementations§
Source§impl IpfsApi
impl IpfsApi
Sourcepub fn cat(&self, hash: &str) -> Result<impl Iterator<Item = u8>, Error>
pub fn cat(&self, hash: &str) -> Result<impl Iterator<Item = u8>, Error>
Retrieves the contents of a file from the IPFS network. Takes a hash and returns an iterator of bytes. The result can be streamed, if the file is large.
let api = IpfsApi::new("127.0.0.1", 5001);
let hello = api.cat("QmWATWQ7fVPP2EFGu71UkfnqhYXDYH566qy47CnJDgvs8u")?;
let hello_string = String::from_utf8(hello.collect())?;
println!("{}", hello_string);
Source§impl IpfsApi
impl IpfsApi
Source§impl IpfsApi
impl IpfsApi
Sourcepub fn block_get(&self, hash: &str) -> Result<impl Iterator<Item = u8>, Error>
pub fn block_get(&self, hash: &str) -> Result<impl Iterator<Item = u8>, Error>
Get a raw IPFS block.
§Notes
This is a wrapper for the /api/v0/block/get
API.
§Errors
This function can return an error if the IPFS node is down, or if the block cannot be retrieved.
§Examples
let api = IpfsApi::new("127.0.0.1", 5001);
let hash = "QmV8cfu6n4NT5xRr2AHdKxFMTZEJrA44qgrBCr739BN9Wb";
let block = api.block_get(hash).unwrap();
let string = String::from_utf8(block.collect()).unwrap();
assert_eq!(string, "Hello world");
Source§impl IpfsApi
impl IpfsApi
Auto Trait Implementations§
impl Freeze for IpfsApi
impl RefUnwindSafe for IpfsApi
impl Send for IpfsApi
impl Sync for IpfsApi
impl Unpin for IpfsApi
impl UnwindSafe for IpfsApi
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