aoc-cache

Crates.ioaoc-cache
lib.rsaoc-cache
version0.2.2
sourcesrc
created_at2022-12-03 23:23:27.324256
updated_at2023-12-05 21:35:55.969962
descriptionA way of caching your input from the great and popular Advent of Code
homepage
repositoryhttps://github.com/glennib/aoc-cache
max_upload_size
id729301
size11,920
Glenn Bitar (glennib)

documentation

README

aoc-cache

A way of caching your input from the great and popular Advent of Code.

This is an attempt to reduce server load for the creator.

Downloads using ureq, stores cache in temporary files using scratch.

Since we use scratch, a cargo clean will remove the cache and cause new downloads for new runs.

Example

use aoc_cache::get;
// my.cookie is a file containing the cookie string.
const MY_COOKIE: &str = include_str!("my.cookie");
let input: Result<String, aoc_cache::Error> = // Grabs from web if
    get(              // it's the first run
        "https://adventofcode.com/2022/day/1/input", MY_COOKIE);
let input: Result<String, aoc_cache::Error> = // Grabs from cache
    get(
        "https://adventofcode.com/2022/day/1/input", MY_COOKIE);

Warning If you use source control for your AoC solutions, take care to not check in any files that contain your cookie into source control!

Example .gitignore:

**/target/
my.cookie
Commit count: 18

cargo fmt