commonware_resolver/
lib.rs1#![doc(
4 html_logo_url = "https://commonware.xyz/imgs/rustdoc_logo.svg",
5 html_favicon_url = "https://commonware.xyz/favicon.ico"
6)]
7
8use commonware_utils::Span;
9use std::future::Future;
10
11pub mod p2p;
12
13pub trait Consumer: Clone + Send + 'static {
15 type Key: Span;
17
18 type Value;
20
21 type Failure;
23
24 fn deliver(&mut self, key: Self::Key, value: Self::Value) -> impl Future<Output = bool> + Send;
28
29 fn failed(&mut self, key: Self::Key, failure: Self::Failure)
33 -> impl Future<Output = ()> + Send;
34}
35
36pub trait Resolver: Clone + Send + 'static {
38 type Key: Span;
40
41 fn fetch(&mut self, key: Self::Key) -> impl Future<Output = ()> + Send;
43
44 fn cancel(&mut self, key: Self::Key) -> impl Future<Output = ()> + Send;
46
47 fn clear(&mut self) -> impl Future<Output = ()> + Send;
49
50 fn retain(
52 &mut self,
53 predicate: impl Fn(&Self::Key) -> bool + Send + 'static,
54 ) -> impl Future<Output = ()> + Send;
55}