Struct ipfs_embed::Ipfs[][src]

pub struct Ipfs<P: StoreParams> { /* fields omitted */ }

Ipfs node.

Implementations

impl<P: StoreParams> Ipfs<P> where
    Ipld: References<P::Codecs>, 
[src]

pub async fn new(config: Config) -> Result<Self>[src]

Creates a new Ipfs from a Config.

This starts three background tasks. The swarm, garbage collector and the dht cleanup tasks run in the background.

pub fn local_peer_id(&self) -> PeerId[src]

Returns the local PeerId.

pub async fn listen_on(&self, addr: Multiaddr) -> Result<Multiaddr>[src]

Listens on a new Multiaddr.

pub fn listeners(&self) -> Vec<Multiaddr>[src]

Returns the currently active listener addresses.

pub fn add_external_address(&self, addr: Multiaddr)[src]

Adds an external address.

pub fn external_addresses(&self) -> Vec<AddressRecord>[src]

Returns the currently used external addresses.

pub fn add_address(&self, peer: &PeerId, addr: Multiaddr)[src]

Adds a known Multiaddr for a PeerId.

pub fn remove_address(&self, peer: &PeerId, addr: &Multiaddr)[src]

Removes a Multiaddr for a PeerId.

pub fn dial(&self, peer: &PeerId) -> Result<()>[src]

Dials a PeerId using a known address.

pub fn dial_address(&self, peer: &PeerId, addr: Multiaddr) -> Result<()>[src]

Dials a PeerId using Multiaddr.

pub fn ban(&self, peer: PeerId)[src]

Bans a PeerId from the swarm, dropping all existing connections and preventing new connections from the peer.

pub fn unban(&self, peer: PeerId)[src]

Unbans a previously banned PeerId.

pub fn peers(&self) -> Vec<PeerId>[src]

Returns the known peers.

pub fn connections(&self) -> Vec<(PeerId, Multiaddr)>[src]

Returns a list of connected peers.

pub fn is_connected(&self, peer: &PeerId) -> bool[src]

Returns true if there is a connection to peer.

pub fn peer_info(&self, peer: &PeerId) -> Option<PeerInfo>[src]

Returns the PeerInfo of a peer.

pub async fn bootstrap(&self, nodes: &[(PeerId, Multiaddr)]) -> Result<()>[src]

Bootstraps the dht using a set of bootstrap nodes. After bootstrap completes it provides all blocks in the block store.

pub async fn get_record(
    &self,
    key: &Key,
    quorum: Quorum
) -> Result<Vec<PeerRecord>>
[src]

Gets a record from the dht.

pub async fn put_record(&self, record: Record, quorum: Quorum) -> Result<()>[src]

Puts a new record in the dht.

pub fn remove_record(&self, key: &Key)[src]

Removes a record from the dht.

pub fn subscribe(&self, topic: &str) -> Result<impl Stream<Item = Vec<u8>>>[src]

Subscribes to a topic returning a Stream of messages. If all Streams for a topic are dropped it unsubscribes from the topic.

pub fn publish(&self, topic: &str, msg: Vec<u8>) -> Result<()>[src]

Publishes a new message in a topic, sending the message to all subscribed peers.

pub fn broadcast(&self, topic: &str, msg: Vec<u8>) -> Result<()>[src]

Publishes a new message in a topic, sending the message to all subscribed connected peers.

pub fn create_temp_pin(&self) -> Result<TempPin>[src]

Creates a temporary pin in the block store. A temporary pin is not persisted to disk and is released once it is dropped.

pub fn temp_pin(&self, tmp: &TempPin, cid: &Cid) -> Result<()>[src]

Adds a new root to a temporary pin.

pub fn iter(&self) -> Result<impl Iterator<Item = Cid>>[src]

Returns an Iterator of Cids stored in the block store.

pub fn contains(&self, cid: &Cid) -> Result<bool>[src]

Checks if the block is in the block store.

pub fn get(&self, cid: &Cid) -> Result<Block<P>>[src]

Returns a block from the block store.

pub async fn fetch(&self, cid: &Cid) -> Result<Block<P>>[src]

Either returns a block if it’s in the block store or tries to retrieve it from a peer.

pub fn insert(
    &self,
    block: &Block<P>
) -> Result<impl Future<Output = Result<()>> + '_>
[src]

Inserts a block in to the block store and announces it to peers.

pub async fn evict(&self) -> Result<()>[src]

Manually runs garbage collection to completion. This is mainly useful for testing and administrative interfaces. During normal operation, the garbage collector automatically runs in the background.

pub fn sync(&self, cid: &Cid) -> SyncQuery<P>

Notable traits for SyncQuery<P>

impl<P: StoreParams> Future for SyncQuery<P> type Output = Result<()>;
[src]

pub fn alias<T: AsRef<[u8]> + Send + Sync>(
    &self,
    alias: T,
    cid: Option<&Cid>
) -> Result<()>
[src]

Creates, updates or removes an alias with a new root Cid.

pub fn resolve<T: AsRef<[u8]> + Send + Sync>(
    &self,
    alias: T
) -> Result<Option<Cid>>
[src]

Returns the root of an alias.

pub fn reverse_alias(&self, cid: &Cid) -> Result<Option<Vec<Vec<u8>>>>[src]

Returns a list of aliases preventing a Cid from being garbage collected.

pub async fn flush(&self) -> Result<()>[src]

Flushes the block store. After flush completes successfully it is guaranteed that all writes have been persisted to disk.

pub fn register_metrics(&self, registry: &Registry) -> Result<()>[src]

Registers prometheus metrics in a registry.

pub fn event_stream(&self) -> impl Stream<Item = Event>[src]

Subscribes to the event stream.

Trait Implementations

impl<P: Clone + StoreParams> Clone for Ipfs<P>[src]

impl<P: StoreParams> Store for Ipfs<P> where
    Ipld: References<P::Codecs>, 
[src]

type Params = P

Store parameters.

type TempPin = Arc<TempPin>

Temp pin.

Auto Trait Implementations

impl<P> !RefUnwindSafe for Ipfs<P>

impl<P> Send for Ipfs<P>

impl<P> Sync for Ipfs<P>

impl<P> Unpin for Ipfs<P>

impl<P> !UnwindSafe for Ipfs<P>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> References<RawCodec> for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,