pub struct PuzzleFsCache { /* private fields */ }Expand description
A file system backed implementation of PuzzleCache.
Cached puzzle data is grouped together by day and year into a directory. The cache layout follows this general pattern:
<cache_dir>/y
cache_dir is specified when PuzzleFsCache::new(...) is called.
year is four digit puzzle year.
day is the puzzle day with no leading zeroes, and starting from index one.
Encryption: If a passphrase is configured, inputs are automatically encrypted when saved and
decrypted when loaded. The .encrypted.txt suffix indicates an encrypted file. Unencrypted
input files use the .txt extension.
Implementations§
Source§impl PuzzleFsCache
impl PuzzleFsCache
Sourcepub fn new<P: Into<PathBuf>, S: Into<String>>(
cache_dir: P,
passphrase: Option<S>,
) -> Self
pub fn new<P: Into<PathBuf>, S: Into<String>>( cache_dir: P, passphrase: Option<S>, ) -> Self
Creates a new PuzzleFsCache that reads/writes cache data stored in cache_dir. Inputs are
are encrypted on disk using the provided passphrase.
Sourcepub fn dir_for_puzzle(cache_dir: &Path, day: Day, year: Year) -> PathBuf
pub fn dir_for_puzzle(cache_dir: &Path, day: Day, year: Year) -> PathBuf
Get the directory path for a puzzle day and year.
Trait Implementations§
Source§impl Debug for PuzzleFsCache
impl Debug for PuzzleFsCache
Source§impl PuzzleCache for PuzzleFsCache
impl PuzzleCache for PuzzleFsCache
Source§fn load_input(&self, day: Day, year: Year) -> Result<Option<String>, CacheError>
fn load_input(&self, day: Day, year: Year) -> Result<Option<String>, CacheError>
Ok(None)
if no cache entry exists.Source§fn load_answers(
&self,
part: Part,
day: Day,
year: Year,
) -> Result<Option<Answers>, CacheError>
fn load_answers( &self, part: Part, day: Day, year: Year, ) -> Result<Option<Answers>, CacheError>
Ok(None) if no cache entry exists.