Tote 
A lightweight data file cache for CLI libraries
For CLIs that query a default set of information with each invocation,
Tote offers a convenient way to cache data to a file for quicker
subsequent CLI runs.
When Tote is used for a cache (examples below), the tote.get() call will:
- Check that the
Totefilepath exists and has been modified within the specified expiry time - Deserialize and return the data
If the cached data is not present or expired, Tote will:
- Use the
Fetch::fetchmethods to retrieve the data - Serialize the data (using
serde_json) and write to theTotefilepath - Return the newly fetched data
Features
Default
The default feature uses a Synchronous Fetch trait:
use Duration;
use ;
use ;
// Implement `serde`'s `Serialize`/`Deserialize` for you own data
// or make a NewType and `derive` so `Tote` can read and write the cached data
;
Async
The "async" feature adds the AsyncFetch trait if you want to use async I/O for fetching data. Call Tote::get_async().await to get the Tote contents.
Cargo.toml
= { = "*", = ["async"] }
use HashMap;
use IpAddr;
use Duration;
use async_trait;
use ;
use ;
// Implement `serde`'s `Serialize`/`Deserialize` for you own data
// or make a NewType and `derive` so `Tote` can read and write the cached data
;
async