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§
Sourcetype Subscriber: Clone + Eq + Send + 'static
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§
Sourcefn fetch<F>(&mut self, key: F) -> Feedback
fn fetch<F>(&mut self, key: F) -> Feedback
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.
Sourcefn retain(
&mut self,
predicate: impl Fn(&Self::Key, &Self::Subscriber) -> bool + Send + 'static,
) -> Feedback
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".