Crates.io | shared-expiry-get |
lib.rs | shared-expiry-get |
version | 0.2.0 |
source | src |
created_at | 2019-05-05 18:56:19.800277 |
updated_at | 2021-01-26 10:32:42.791314 |
description | Simple concurrent async get with expiration for Rust |
homepage | |
repository | https://github.com/fiji-flo/shared-expiry-get |
max_upload_size | |
id | 132266 |
size | 57,545 |
shared-expiry-get
is a wrapper for accessing and caching a remote data source with some
expiration criteria.
shared-expiry-get
does not:
#[derive(Clone)]
struct MyProvider {}
#[derive(Clone)]
struct Payload {}
impl Expiry for Payload {
fn valid(&self) -> bool {
true
}
}
impl Provider<Payload> for MyProvider {
fn update(&self) -> ExpiryFut<Payload> {
future::ok::<Payload, ExpiryGetError>(Payload {}).into_future().boxed()
}
}
async fn main() {
let rs = RemoteStore::new(MyProvider {});
let payload = rs.get().await;
assert!(payload.is_ok());
}