Skip to main content

Resolver

Trait Resolver 

Source
pub trait Resolver:
    Clone
    + Send
    + 'static {
    type Key: Span;
    type Subscriber: Clone + Eq + Send + 'static;

    // Required methods
    fn fetch<F>(&mut self, key: F) -> Feedback
       where F: Into<Fetch<Self::Key, Self::Subscriber>> + Send;
    fn fetch_all<F>(&mut self, keys: Vec<F>) -> Feedback
       where F: Into<Fetch<Self::Key, Self::Subscriber>> + Send;
    fn retain(
        &mut self,
        predicate: impl Fn(&Self::Key, &Self::Subscriber) -> bool + Send + 'static,
    ) -> Feedback;
}
Expand description

Responsible for fetching data and notifying a Consumer.

Required Associated Types§

Source

type Key: Span

Type used to key data requested from peers.

Source

type Subscriber: Clone + Eq + Send + 'static

Type used to track subscribers on fetch keys.

Implementations that also own the Consumer should supply subscribers to Consumer::deliver when a fetch resolves.

Required Methods§

Source

fn fetch<F>(&mut self, key: F) -> Feedback
where F: Into<Fetch<Self::Key, Self::Subscriber>> + Send,

Initiate a fetch.

The resolver fetches and delivers the key. The subscriber is retained and supplied to Consumer::deliver when the fetch resolves. If multiple subscribers are attached to the same key, the fetch is retained as long as at least one subscriber satisfies the latest retain predicate.

Passing a bare key is supported when Subscriber: Default.

Source

fn fetch_all<F>(&mut self, keys: Vec<F>) -> Feedback
where F: Into<Fetch<Self::Key, Self::Subscriber>> + Send,

Initiate fetches for a batch of keys.

Source

fn retain( &mut self, predicate: impl Fn(&Self::Key, &Self::Subscriber) -> bool + Send + 'static, ) -> Feedback

Retain only fetch subscribers satisfying the predicate.

The predicate receives the peer-visible key and subscriber.

Fetches not retained are canceled. If response validation is in progress, cancellation may drop the Consumer::deliver future before it reports whether the data was valid.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<K, P, S> Resolver for Mailbox<K, P, S>
where K: Span, P: PublicKey, S: Clone + Eq + Send + 'static,

Source§

impl<K, S, P> Resolver for Resolver<K, S, P>
where K: Span, S: Clone + Eq + Send + 'static, P: PublicKey,