Expand description
§shared-expiry-get
shared-expiry-get is a wrapper for accessing and caching a remote data source with some
expiration criteria.
§A basic Example
use futures::executor::block_on;
use futures::future;
use futures::future::FutureExt;
use futures::future::IntoFuture;
use futures::future::TryFutureExt;
use futures::Future;
use std::pin::Pin;
use shared_expiry_get::Expiry;
use shared_expiry_get::ExpiryFut;
use shared_expiry_get::ExpiryGetError;
use shared_expiry_get::Provider;
use shared_expiry_get::RemoteStore;
#[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()
}
}
let rs = RemoteStore::new(MyProvider {});
let payload = block_on(rs.get());
assert!(payload.is_ok());
Structs§
- Remote
Store - A remote store wrapping an updated provider (
impl Provider) and remote data type (impl Expiry).
Enums§
- Expiry
GetError - Various internal errors.
Traits§
- Expiry
- Used to determine whether the remote data is still valid.
- Provider
- Provides updates to get remote data.