Trait Store

pub trait Store {
    type FromStore: Debug + Send;

    // Required methods
    fn on_swarm_event(&mut self, event: &FromSwarm<'_>);
    fn addresses_of_peer(
        &self,
        peer: &PeerId,
    ) -> Option<impl Iterator<Item = &Multiaddr>>;
    fn poll(&mut self, cx: &mut Context<'_>) -> Option<Event<Self::FromStore>>;
}
Available on crate feature peer-store only.
Expand description

A store that contains all observed addresses of peers.

Required Associated Types§

type FromStore: Debug + Send

Event generated by the store and emitted to Swarm. Behaviour cannot handle this event.

Required Methods§

fn on_swarm_event(&mut self, event: &FromSwarm<'_>)

How this store handles events from Swarm.

fn addresses_of_peer( &self, peer: &PeerId, ) -> Option<impl Iterator<Item = &Multiaddr>>

Get all stored addresses of the peer.

fn poll(&mut self, cx: &mut Context<'_>) -> Option<Event<Self::FromStore>>

Polls for things that the store should do.
The task should be waked up to emit events to Behaviour and Swarm.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

§

impl<T> Store for MemoryStore<T>