Struct rust_ipfs::UninitializedIpfs
source · pub struct UninitializedIpfs<Types: IpfsTypes> { /* private fields */ }
Expand description
Configured Ipfs which can only be started.
Implementations§
source§impl<Types: IpfsTypes> UninitializedIpfs<Types>
impl<Types: IpfsTypes> UninitializedIpfs<Types>
sourcepub fn new(options: IpfsOptions) -> Self
pub fn new(options: IpfsOptions) -> Self
Configures a new UninitializedIpfs with from the given options and optionally a span.
If the span is not given, it is defaulted to tracing::trace_span!("ipfs")
.
The span is attached to all operations called on the later created Ipfs
along with all
operations done in the background task as well as tasks spawned by the underlying
libp2p::Swarm
.
sourcepub fn swarm_events<F>(self, func: F) -> Selfwhere
F: Fn(&mut TSwarm, &<TSwarm as Stream>::Item) + Sync + Send + 'static,
pub fn swarm_events<F>(self, func: F) -> Selfwhere
F: Fn(&mut TSwarm, &<TSwarm as Stream>::Item) + Sync + Send + 'static,
Handle libp2p swarm events
sourcepub async fn spawn_start(self) -> Result<Ipfs<Types>, Error>
pub async fn spawn_start(self) -> Result<Ipfs<Types>, Error>
Same as crate::UninitializedIpfs::start
except we use tokio::spawn
internally
sourcepub async fn start(
self
) -> Result<(Ipfs<Types>, impl Future<Output = ()>), Error>
pub async fn start(
self
) -> Result<(Ipfs<Types>, impl Future<Output = ()>), Error>
Initialize the ipfs node. The returned Ipfs
value is cloneable, send and sync, and the
future should be spawned on a executor as soon as possible.
The future returned from this method should not need
(instrumenting)tracing_futures::Instrument::instrument
as the IpfsOptions::span
will be used as parent span for all of the awaited and created futures.