pub trait Resolver:
Clone
+ Send
+ 'static {
type Key: Span;
type PublicKey: PublicKey;
// Required methods
fn fetch(&mut self, key: Self::Key) -> impl Future<Output = ()> + Send;
fn fetch_all(
&mut self,
keys: Vec<Self::Key>,
) -> impl Future<Output = ()> + Send;
fn fetch_targeted(
&mut self,
key: Self::Key,
targets: NonEmptyVec<Self::PublicKey>,
) -> impl Future<Output = ()> + Send;
fn fetch_all_targeted(
&mut self,
requests: Vec<(Self::Key, NonEmptyVec<Self::PublicKey>)>,
) -> impl Future<Output = ()> + Send;
fn cancel(&mut self, key: Self::Key) -> impl Future<Output = ()> + Send;
fn clear(&mut self) -> impl Future<Output = ()> + Send;
fn retain(
&mut self,
predicate: impl Fn(&Self::Key) -> bool + Send + 'static,
) -> impl Future<Output = ()> + Send;
}Expand description
Responsible for fetching data and notifying a Consumer.
Required Associated Types§
Required Methods§
Sourcefn fetch(&mut self, key: Self::Key) -> impl Future<Output = ()> + Send
fn fetch(&mut self, key: Self::Key) -> impl Future<Output = ()> + Send
Initiate a fetch request for a single key.
Sourcefn fetch_all(&mut self, keys: Vec<Self::Key>) -> impl Future<Output = ()> + Send
fn fetch_all(&mut self, keys: Vec<Self::Key>) -> impl Future<Output = ()> + Send
Initiate a fetch request for a batch of keys.
Sourcefn fetch_targeted(
&mut self,
key: Self::Key,
targets: NonEmptyVec<Self::PublicKey>,
) -> impl Future<Output = ()> + Send
fn fetch_targeted( &mut self, key: Self::Key, targets: NonEmptyVec<Self::PublicKey>, ) -> impl Future<Output = ()> + Send
Initiate a fetch request restricted to specific target peers.
Only target peers are tried, there is no fallback to other peers. Targets persist through transient failures (timeout, “no data” response, send failure) since the peer might be slow or might receive the data later.
If a fetch is already in progress for this key:
- If the existing fetch has targets, the new targets are added to the set
- If the existing fetch has no targets (can try any peer), it remains unrestricted (this call is ignored)
To clear targeting and fall back to any peer, call fetch.
Targets are automatically cleared when the fetch succeeds or is canceled. When a peer is blocked (sent invalid data), only that peer is removed from the target set.
Sourcefn fetch_all_targeted(
&mut self,
requests: Vec<(Self::Key, NonEmptyVec<Self::PublicKey>)>,
) -> impl Future<Output = ()> + Send
fn fetch_all_targeted( &mut self, requests: Vec<(Self::Key, NonEmptyVec<Self::PublicKey>)>, ) -> impl Future<Output = ()> + Send
Initiate fetch requests for multiple keys, each with their own targets.
See fetch_targeted for details on target behavior.
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.