Struct queue_times::client::CachedClient [−][src]
pub struct CachedClient<T> where
T: QueueTimesClient + Send + Sync, { /* fields omitted */ }
Expand description
Thread-safe cache wrapper for a QueueTimesClient
.
Details
The cached client will only hit the API every five minutes, as that is the rate that the queue times website updates wait times. This means that this client is far more efficient if large numbers of requests are made to the API, such as when being used in a server. The internal state and thread-safe nature do however add considerable overhead in scenarios where only occasional calls are made, so a choice must be made depending on your use case.
Example
use queue_times::client::{Client, QueueTimesClient, CachedClient}; let client = Client::new(); let client = CachedClient::new(client); //The only added line! let parks = client.get_park_urls().await?; let cedar_point_waits = client.get_ride_times(parks.get("Cedar Point")?.to_owned()).await?; let mille_wait = cedar_point_waits.iter().find(|r| r.name == "Millennium Force").unwrap(); println!("The current wait for Millennium Force is: {:?}", mille_wait.status)
Implementations
Trait Implementations
Retrieves a map of park names to the url of their rides page. Read more
Auto Trait Implementations
impl<T> !RefUnwindSafe for CachedClient<T>
impl<T> Send for CachedClient<T>
impl<T> Sync for CachedClient<T>
impl<T> Unpin for CachedClient<T> where
T: Unpin,
impl<T> UnwindSafe for CachedClient<T> where
T: UnwindSafe,