PuzzleCache

Trait PuzzleCache 

Source
pub trait PuzzleCache: Debug {
    // Required methods
    fn load_input(
        &self,
        day: Day,
        year: Year,
    ) -> Result<Option<String>, CacheError>;
    fn load_answers(
        &self,
        part: Part,
        day: Day,
        year: Year,
    ) -> Result<Option<Answers>, CacheError>;
    fn save_input(
        &self,
        input: &str,
        day: Day,
        year: Year,
    ) -> Result<(), CacheError>;
    fn save_answers(
        &self,
        answers: &Answers,
        part: Part,
        day: Day,
        year: Year,
    ) -> Result<(), CacheError>;

    // Provided method
    fn save(&self, puzzle: Puzzle) -> Result<(), CacheError> { ... }
}
Expand description

Caches puzzle inputs and answers to allow retrieval without having to request data from the Advent of Code service.

Input data should be encrypted when written to storage, as requested by the Advent of Code owner. Answers do not need to be encrypted.

Required Methods§

Source

fn load_input(&self, day: Day, year: Year) -> Result<Option<String>, CacheError>

Load input for the given day and year. Returns the decrypted input if cached, or Ok(None) if no cache entry exists.

Source

fn load_answers( &self, part: Part, day: Day, year: Year, ) -> Result<Option<Answers>, CacheError>

Load answers for the given part, day and year. Returns Ok(None) if no cache entry exists.

Source

fn save_input( &self, input: &str, day: Day, year: Year, ) -> Result<(), CacheError>

Save input for the given day and year. The input is encrypted before being written to disk if a passphrase is provided. Any previously saved input for this day and year will be overwritten.

Source

fn save_answers( &self, answers: &Answers, part: Part, day: Day, year: Year, ) -> Result<(), CacheError>

Save answers for the given part, day and year. Any previously saved answers for this day and year will be overwritten.

Provided Methods§

Source

fn save(&self, puzzle: Puzzle) -> Result<(), CacheError>

Save a puzzle’s input and answers for both parts to the cache.

Implementors§