pub struct IpfsApi { /* private fields */ }
Implementations§
Source§impl IpfsApi
impl IpfsApi
pub async fn add(&self, data: Bytes) -> Result<String, Error>
Sourcepub async fn cat(&self, hash: &str) -> Result<Bytes, Error>
pub async fn cat(&self, hash: &str) -> Result<Bytes, 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);
pub async fn get(&self, hash: &str) -> Result<Bytes, Error>
Source§impl IpfsApi
impl IpfsApi
Source§impl IpfsApi
impl IpfsApi
Sourcepub async fn object_stats(&self, hash: &str) -> Result<ObjectStats, Error>
pub async fn object_stats(&self, hash: &str) -> Result<ObjectStats, Error>
Get stats for an IPFS hash. It can be used to get the recursive size of a hash.
Source§impl IpfsApi
impl IpfsApi
Sourcepub async fn pin_add(
&self,
hash: &str,
recursive: bool,
) -> Result<PinResponse, Error>
pub async fn pin_add( &self, hash: &str, recursive: bool, ) -> Result<PinResponse, Error>
Tells the IPFS server to pin the given object. If ‘recursive’ is true, it will recursively pin all objects that one depends on. If ‘progress’ is true, it will return a percentage(?) progress if the object has not been already pinned, or None if it has.
Source§impl IpfsApi
impl IpfsApi
Sourcepub async fn pubsub_subscribe(
&self,
channel: &str,
) -> Result<impl Iterator<Item = PubSubMessage>, Error>
pub async fn pubsub_subscribe( &self, channel: &str, ) -> Result<impl Iterator<Item = PubSubMessage>, Error>
Subscribes to a channel for p2p messages This function subscribes to a channel/topic and listens to any data sent to it. It can be used for peer-to-peer communication and dynamic apps over IPFS.
ⓘ
let api = IpfsApi::new("127.0.0.1", 5001);
for message in api.pubsub_subscribe("chat")? {
println!("{:?}", message);
}
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