Struct ipfs_embed::Ipfs [−][src]
Ipfs node.
Implementations
impl<P: StoreParams> Ipfs<P> where
Ipld: References<P::Codecs>,
[src]
Ipld: References<P::Codecs>,
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 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]
&self,
key: &Key,
quorum: Quorum
) -> Result<Vec<PeerRecord>>
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 Stream
s 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 Cid
s 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]
&self,
block: &Block<P>
) -> Result<impl Future<Output = Result<()>> + '_>
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>ⓘ
[src]
pub fn alias<T: AsRef<[u8]> + Send + Sync>(
&self,
alias: T,
cid: Option<&Cid>
) -> Result<()>
[src]
&self,
alias: T,
cid: Option<&Cid>
) -> Result<()>
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]
&self,
alias: T
) -> Result<Option<Cid>>
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.
Trait Implementations
impl<P: Clone + StoreParams> Clone for Ipfs<P>
[src]
impl<P: StoreParams> Store for Ipfs<P> where
Ipld: References<P::Codecs>,
[src]
Ipld: References<P::Codecs>,
type Params = P
Store parameters.
type TempPin = Arc<TempPin>
Temp pin.
fn create_temp_pin(&self) -> Result<Self::TempPin>
[src]
fn temp_pin(&self, tmp: &Self::TempPin, cid: &Cid) -> Result<()>
[src]
fn contains(&self, cid: &Cid) -> Result<bool>
[src]
fn get(&self, cid: &Cid) -> Result<Block<P>>
[src]
fn insert(&self, block: &Block<P>) -> Result<()>
[src]
fn alias<T: AsRef<[u8]> + Send + Sync>(
&self,
alias: T,
cid: Option<&Cid>
) -> Result<()>
[src]
&self,
alias: T,
cid: Option<&Cid>
) -> Result<()>
fn resolve<T: AsRef<[u8]> + Send + Sync>(&self, alias: T) -> Result<Option<Cid>>
[src]
fn reverse_alias(&self, cid: &Cid) -> Result<Option<Vec<Vec<u8>>>>
[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]
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
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]
&'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,
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]
&'life0 self,
cid: &'life1 Cid
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
#[must_use]pub 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]
&'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>,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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,
_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,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
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]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
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]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,