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]
impl<P: StoreParams> Ipfs<P> where
Ipld: References<P::Codecs>,
[src]pub async fn new(config: Config) -> Result<Self>
[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]
pub fn local_peer_id(&self) -> PeerId
[src]Returns the local PeerId
.
pub fn local_node_name(&self) -> String
[src]
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]
pub fn listen_on(
&self,
addr: Multiaddr
) -> Result<impl Stream<Item = ListenerEvent>>
[src]Listens on a new Multiaddr
.
pub fn add_external_address(&self, addr: Multiaddr)
[src]
pub fn add_external_address(&self, addr: Multiaddr)
[src]Adds an external address.
pub fn external_addresses(&self) -> Vec<AddressRecord>
[src]
pub fn external_addresses(&self) -> Vec<AddressRecord>
[src]Returns the currently used external addresses.
pub fn add_address(&self, peer: &PeerId, addr: Multiaddr)
[src]
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]
pub fn remove_address(&self, peer: &PeerId, addr: &Multiaddr)
[src]Removes a Multiaddr
for a PeerId
.
pub fn dial_address(&self, peer: &PeerId, addr: Multiaddr)
[src]
pub fn dial_address(&self, peer: &PeerId, addr: Multiaddr)
[src]Dials a PeerId
using Multiaddr
.
pub fn ban(&self, peer: PeerId)
[src]
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 is_connected(&self, peer: &PeerId) -> bool
[src]
pub fn is_connected(&self, peer: &PeerId) -> bool
[src]Returns true
if there is a connection to peer.
pub async fn bootstrap(&self, nodes: &[(PeerId, Multiaddr)]) -> Result<()>
[src]
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]
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]
pub async fn providers(&self, key: Key) -> Result<HashSet<PeerId>>
[src]Gets providers of a key from the dht.
pub async fn get_record(
&self,
key: &Key,
quorum: Quorum
) -> Result<Vec<PeerRecord>>
[src]
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]
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]
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]
pub fn subscribe(&self, topic: &str) -> Result<impl Stream<Item = Vec<u8>>>
[src]Subscribes to a topic
returning a Stream
of messages. If all Stream
s for
a topic are dropped it unsubscribes from the topic
.
pub fn publish(&self, topic: &str, msg: Vec<u8>) -> Result<()>
[src]
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]
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]
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]
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]
pub fn iter(&self) -> Result<impl Iterator<Item = Cid>>
[src]Returns an Iterator
of Cid
s stored in the block store.
pub async fn fetch(&self, cid: &Cid, providers: Vec<PeerId>) -> Result<Block<P>>
[src]
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 async fn evict(&self) -> Result<()>
[src]
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>ⓘ
[src]
pub fn alias<T: AsRef<[u8]> + Send + Sync>(
&self,
alias: T,
cid: Option<&Cid>
) -> 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]
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]
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]
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]
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]
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]
impl<P: Clone + StoreParams> Clone for Ipfs<P>
[src]impl<P: StoreParams> Debug for Ipfs<P>
[src]
impl<P: StoreParams> Debug for Ipfs<P>
[src]impl<P: StoreParams> Store for Ipfs<P> where
Ipld: References<P::Codecs>,
[src]
impl<P: StoreParams> Store for Ipfs<P> where
Ipld: References<P::Codecs>,
[src]type Params = P
type Params = P
Store parameters.
fn create_temp_pin(&self) -> Result<Self::TempPin>
[src]
fn create_temp_pin(&self) -> Result<Self::TempPin>
[src]Creates a new temporary pin.
fn get(&self, cid: &Cid) -> Result<Block<P>>
[src]
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]
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]
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]
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]
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]
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]
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]
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]
#[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> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[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]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
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]
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<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,