[−][src]Struct libp2p_core::nodes::tasks::Manager
Implementation of Stream that handles a collection of nodes.
Methods
impl<I, O, H, E, HE, T, C> Manager<I, O, H, E, HE, T, C>[src]
pub fn new(executor: Option<Box<dyn Executor + Send>>) -> Self[src]
Creates a new task manager. If Some is passed, uses the given executor to spawn tasks.
Otherwise, background tasks are executed locally when you call poll.
pub fn add_reach_attempt<F, M>(
&mut self,
future: F,
user_data: T,
handler: H
) -> TaskId where
F: Future<Output = Result<(C, M), E>> + Send + 'static,
H: IntoNodeHandler<C> + Send + 'static,
H::Handler: NodeHandler<Substream = Substream<M>, InEvent = I, OutEvent = O, Error = HE> + Send + 'static,
E: Error + Send + 'static,
HE: Error + Send + 'static,
I: Send + 'static,
O: Send + 'static,
<H::Handler as NodeHandler>::OutboundOpenInfo: Send + 'static,
M: StreamMuxer + Send + Sync + 'static,
M::OutboundSubstream: Send + 'static,
C: Send + 'static, [src]
&mut self,
future: F,
user_data: T,
handler: H
) -> TaskId where
F: Future<Output = Result<(C, M), E>> + Send + 'static,
H: IntoNodeHandler<C> + Send + 'static,
H::Handler: NodeHandler<Substream = Substream<M>, InEvent = I, OutEvent = O, Error = HE> + Send + 'static,
E: Error + Send + 'static,
HE: Error + Send + 'static,
I: Send + 'static,
O: Send + 'static,
<H::Handler as NodeHandler>::OutboundOpenInfo: Send + 'static,
M: StreamMuxer + Send + Sync + 'static,
M::OutboundSubstream: Send + 'static,
C: Send + 'static,
Adds to the manager a future that tries to reach a node.
This method spawns a task dedicated to resolving this future and processing the node's events.
pub fn add_connection<M, Handler>(
&mut self,
user_data: T,
muxer: M,
handler: Handler
) -> TaskId where
H: IntoNodeHandler<C, Handler = Handler> + Send + 'static,
Handler: NodeHandler<Substream = Substream<M>, InEvent = I, OutEvent = O, Error = HE> + Send + 'static,
E: Error + Send + 'static,
HE: Error + Send + 'static,
I: Send + 'static,
O: Send + 'static,
<H::Handler as NodeHandler>::OutboundOpenInfo: Send + 'static,
M: StreamMuxer + Send + Sync + 'static,
M::OutboundSubstream: Send + 'static,
C: Send + 'static, [src]
&mut self,
user_data: T,
muxer: M,
handler: Handler
) -> TaskId where
H: IntoNodeHandler<C, Handler = Handler> + Send + 'static,
Handler: NodeHandler<Substream = Substream<M>, InEvent = I, OutEvent = O, Error = HE> + Send + 'static,
E: Error + Send + 'static,
HE: Error + Send + 'static,
I: Send + 'static,
O: Send + 'static,
<H::Handler as NodeHandler>::OutboundOpenInfo: Send + 'static,
M: StreamMuxer + Send + Sync + 'static,
M::OutboundSubstream: Send + 'static,
C: Send + 'static,
Adds an existing connection to a node to the collection.
This method spawns a task dedicated to processing the node's events.
No NodeReached event will be emitted for this task, since the node has already been
reached.
#[must_use]
pub fn poll_broadcast(&mut self, event: &I, cx: &mut Context) -> Poll<()> where
I: Clone, [src]
I: Clone,
Sends a message to all the tasks, including the pending ones.
This function is "atomic", in the sense that if Poll::Pending is returned then no event
has been sent to any node yet.
pub fn task(&mut self, id: TaskId) -> Option<TaskEntry<I, T>>[src]
Grants access to an object that allows controlling a task of the collection.
Returns None if the task id is invalid.
pub fn tasks<'a>(&'a self) -> impl Iterator<Item = TaskId> + 'a[src]
Returns a list of all the active tasks.
pub fn poll(&mut self, cx: &mut Context) -> Poll<Event<I, O, H, E, HE, T, C>>[src]
Provides an API similar to Stream, except that it cannot produce an error.
Trait Implementations
Auto Trait Implementations
impl<I, O, H, E, HE, T, C = PeerId> !RefUnwindSafe for Manager<I, O, H, E, HE, T, C>
impl<I, O, H, E, HE, T, C> Send for Manager<I, O, H, E, HE, T, C> where
C: Send,
E: Send,
H: Send,
HE: Send,
I: Send,
O: Send,
T: Send,
C: Send,
E: Send,
H: Send,
HE: Send,
I: Send,
O: Send,
T: Send,
impl<I, O, H, E, HE, T, C = PeerId> !Sync for Manager<I, O, H, E, HE, T, C>
impl<I, O, H, E, HE, T, C> Unpin for Manager<I, O, H, E, HE, T, C> where
T: Unpin,
T: Unpin,
impl<I, O, H, E, HE, T, C = PeerId> !UnwindSafe for Manager<I, O, H, E, HE, T, C>
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,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
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.
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.
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>,