Struct ipfs_embed::Ipfs[][src]

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

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 fn local_node_name(&self) -> String[src]

Returns the local node name.

pub fn listen_on(
    &self,
    addr: Multiaddr
) -> Result<impl Stream<Item = ListenerEvent>>
[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)[src]

Dials a PeerId using a known address.

pub fn dial_address(&self, peer: &PeerId, addr: Multiaddr)[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_closest_peers<K>(&self, key: K) -> Result<()> where
    K: Into<BucketKey<K>> + Into<Vec<u8>> + Clone
[src]

Gets the closest peer to a key. Useful for finding the Multiaddr of a PeerId.

pub async fn providers(&self, key: Key) -> Result<HashSet<PeerId>>[src]

Gets providers of a key from the dht.

pub async fn provide(&self, key: Key) -> Result<()>[src]

Provides a key in the dht.

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

Stops providing a key in the dht.

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, providers: Vec<PeerId>) -> 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<()>[src]

Inserts a block in to the block store.

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, providers: Vec<PeerId>) -> 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 swarm_events(&self) -> impl Stream<Item = Event>[src]

Subscribes to the swarm event stream.

Trait Implementations

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

fn clone(&self) -> Ipfs<P>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<P: StoreParams> Debug for Ipfs<P>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

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

type Params = P

Store parameters.

type TempPin = Arc<TempPin>

Temp pin.

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

Creates a new temporary pin.

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

Adds a block to a temp pin.

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

Returns true if the store contains the block.

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

Returns a block from the store. If the block wasn’t found it returns a BlockNotFound error. Read more

fn insert(&self, block: &Block<P>) -> Result<()>[src]

Inserts a block into the store and publishes the block on the network.

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

Creates an alias for a Cid.

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

Resolves an alias for a Cid.

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

Returns all the aliases that are keeping the block around.

fn flush<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 
[src]

Flushes the store.

fn fetch<'life0, 'life1, 'async_trait>(
    &'life0 self,
    cid: &'life1 Cid
) -> Pin<Box<dyn Future<Output = Result<Block<Self::Params>>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

Returns a block from the store. If the store supports networking and the block is not in the store it fetches it from the network and inserts it into the store. Dropping the future cancels the request. Read more

fn sync<'life0, 'life1, 'async_trait>(
    &'life0 self,
    cid: &'life1 Cid
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

Fetches all missing blocks recursively from the network. If a block isn’t found it returns a BlockNotFound error. Read more

#[must_use]
fn query<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    path: &'life1 DagPath<'life2>
) -> Pin<Box<dyn Future<Output = Result<Ipld, Error>> + 'async_trait + Send, Global>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait,
    Ipld: Decode<<Self::Params as StoreParams>::Codecs>, 
[src]

Resolves a path recursively and returns the ipld.

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]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

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

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

fn in_current_span(self) -> Instrumented<Self>[src]

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

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

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> References<RawCodec> for T

pub fn references<R, E>(
    _c: RawCodec,
    _r: &mut R,
    _set: &mut E
) -> Result<(), Error> where
    E: Extend<Cid<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>>>,
    R: Read

Scrape the references from an impl Read. Read more

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.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

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

Performs the conversion.

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.

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

Performs the conversion.

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

pub fn vzip(self) -> V