Struct IpfsApi

Source
pub struct IpfsApi { /* private fields */ }

Implementations§

Source§

impl IpfsApi

Source

pub async fn add(&self, data: Bytes) -> Result<String, Error>

Source

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);
Source

pub async fn get(&self, hash: &str) -> Result<Bytes, Error>

Source§

impl IpfsApi

Source

pub async fn name_resolve(&self, name: &str) -> Result<String, Error>

Resolve an IPNS hash or a domain name

let api = IpfsApi::new("127.0.0.1", 5001);
let hash = api.name_resolve("gkbrk.com");

println!("{}", hash);
Source

pub async fn name_publish(&self, hash: &str) -> Result<(), Error>

Publish an IPFS hash in IPNS.

Source§

impl IpfsApi

Source

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

Source

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

pub async fn pin_rm( &self, hash: &str, recursive: bool, ) -> Result<PinResponse, Error>

Unpin the given object.

Source

pub async fn pin_list(&self) -> Result<Vec<PinnedHash>, Error>

List pinned objects.

Source§

impl IpfsApi

Source

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);
}
Source

pub async fn pubsub_publish( &self, channel: &str, data: &str, ) -> Result<(), Error>

Sends a p2p message to a channel This function sends a data packet to a channel/topic. It can be used for peer-to-peer communication and dynamic apps over IPFS.

Source§

impl IpfsApi

Source

pub async fn version(&self) -> Result<IpfsVersion, Error>

Get the version from the IPFS daemon.

Source§

impl IpfsApi

Source

pub async fn shutdown(&self) -> Result<(), Error>

Shut down the IPFS daemon This function causes the IPFS daemon to terminate

Source§

impl IpfsApi

Source

pub async fn block_put<'a>(&'a self, data: Bytes) -> Result<String, Error>

Source

pub async fn block_get(&self, hash: &str) -> Result<Bytes, Error>

Source§

impl IpfsApi

The main interface of the library The IpfsApi class represents a connection to the local IPFS daemon. It can read and write data to it using http requests to the server.

Source

pub fn new(server: &str, port: u16) -> IpfsApi

Creates a new instance of the API

let api = IpfsApi::new("127.0.0.1", 5001);

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,