Struct queue_times::client::CachedClient[][src]

pub struct CachedClient<T> where
    T: QueueTimesClient + Send + Sync + 'static, 
{ /* 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.

The implimentation will eagerly return results, but lazaly updates cache. This means that if the client is never called, then it will never update the cache. But if it does need to update the cache, it will first return the result of the request, while the cache updates in the background.

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

Wraps the passed client with a cache.

Trait Implementations

Returns the “default value” for a type. Read more

Retrieves a map of park names to the url of their rides page. Read more

Retrieves the queue times for all parsable rides on a park rides page. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.