pub struct Aoc {
pub year: Option<i32>,
pub day: Option<u32>,
pub level: Level,
pub title: Option<String>,
pub stars: Option<u8>,
pub solution: HashMap<Level, String>,
/* private fields */
}
Expand description
A cache entry for a single day, containing all data related to that day’s problem
Fields§
§year: Option<i32>
§day: Option<u32>
§level: Level
§title: Option<String>
§stars: Option<u8>
§solution: HashMap<Level, String>
Implementations§
Source§impl Aoc
impl Aoc
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/day01.rs (line 6)
5fn main() {
6 let mut aoc = Aoc::new()
7 .year(Some(2019))
8 .day(Some(1))
9 .cookie_file("./examples/cookie")
10 .init()
11 .unwrap();
12
13 let input = if let Ok(i) = aoc.get_input(false) {
14 i
15 } else {
16 "you probably need to add a valid cookie".to_string()
17 };
18
19 println!("{}", input);
20}
More examples
examples/day02.rs (line 6)
5fn main() {
6 let mut aoc = Aoc::new()
7 .year(Some(2019))
8 .day(Some(2))
9 .cookie("yoursessioncookiedatagoeshere")
10 .init()
11 .unwrap();
12
13 let input = if let Ok(i) = aoc.get_input(false) {
14 i
15 } else {
16 "you probably need to add a valid cookie".to_string()
17 };
18
19 println!("{}", input);
20}
Sourcepub fn year(self, year: Option<i32>) -> Self
pub fn year(self, year: Option<i32>) -> Self
Set the year
Examples found in repository?
examples/day01.rs (line 7)
5fn main() {
6 let mut aoc = Aoc::new()
7 .year(Some(2019))
8 .day(Some(1))
9 .cookie_file("./examples/cookie")
10 .init()
11 .unwrap();
12
13 let input = if let Ok(i) = aoc.get_input(false) {
14 i
15 } else {
16 "you probably need to add a valid cookie".to_string()
17 };
18
19 println!("{}", input);
20}
More examples
examples/day02.rs (line 7)
5fn main() {
6 let mut aoc = Aoc::new()
7 .year(Some(2019))
8 .day(Some(2))
9 .cookie("yoursessioncookiedatagoeshere")
10 .init()
11 .unwrap();
12
13 let input = if let Ok(i) = aoc.get_input(false) {
14 i
15 } else {
16 "you probably need to add a valid cookie".to_string()
17 };
18
19 println!("{}", input);
20}
Sourcepub fn day(self, day: Option<u32>) -> Self
pub fn day(self, day: Option<u32>) -> Self
Set the day
Examples found in repository?
examples/day01.rs (line 8)
5fn main() {
6 let mut aoc = Aoc::new()
7 .year(Some(2019))
8 .day(Some(1))
9 .cookie_file("./examples/cookie")
10 .init()
11 .unwrap();
12
13 let input = if let Ok(i) = aoc.get_input(false) {
14 i
15 } else {
16 "you probably need to add a valid cookie".to_string()
17 };
18
19 println!("{}", input);
20}
More examples
examples/day02.rs (line 8)
5fn main() {
6 let mut aoc = Aoc::new()
7 .year(Some(2019))
8 .day(Some(2))
9 .cookie("yoursessioncookiedatagoeshere")
10 .init()
11 .unwrap();
12
13 let input = if let Ok(i) = aoc.get_input(false) {
14 i
15 } else {
16 "you probably need to add a valid cookie".to_string()
17 };
18
19 println!("{}", input);
20}
Set cookie string
Examples found in repository?
examples/day02.rs (line 9)
5fn main() {
6 let mut aoc = Aoc::new()
7 .year(Some(2019))
8 .day(Some(2))
9 .cookie("yoursessioncookiedatagoeshere")
10 .init()
11 .unwrap();
12
13 let input = if let Ok(i) = aoc.get_input(false) {
14 i
15 } else {
16 "you probably need to add a valid cookie".to_string()
17 };
18
19 println!("{}", input);
20}
Set cookie file
Examples found in repository?
examples/day01.rs (line 9)
5fn main() {
6 let mut aoc = Aoc::new()
7 .year(Some(2019))
8 .day(Some(1))
9 .cookie_file("./examples/cookie")
10 .init()
11 .unwrap();
12
13 let input = if let Ok(i) = aoc.get_input(false) {
14 i
15 } else {
16 "you probably need to add a valid cookie".to_string()
17 };
18
19 println!("{}", input);
20}
Sourcepub fn parse_cli(self, status: bool) -> Self
pub fn parse_cli(self, status: bool) -> Self
Enable or disable CLI argument parsing
If enabled, the binary’s arguments will be parsed, allowing for example, to choose a file to read in as alternative input data, rather than using the input data fetched from Advent of Code.
Sourcepub fn init(self) -> Result<Self, Error>
pub fn init(self) -> Result<Self, Error>
Initialise (finish building)
Examples found in repository?
examples/day01.rs (line 10)
5fn main() {
6 let mut aoc = Aoc::new()
7 .year(Some(2019))
8 .day(Some(1))
9 .cookie_file("./examples/cookie")
10 .init()
11 .unwrap();
12
13 let input = if let Ok(i) = aoc.get_input(false) {
14 i
15 } else {
16 "you probably need to add a valid cookie".to_string()
17 };
18
19 println!("{}", input);
20}
More examples
examples/day02.rs (line 10)
5fn main() {
6 let mut aoc = Aoc::new()
7 .year(Some(2019))
8 .day(Some(2))
9 .cookie("yoursessioncookiedatagoeshere")
10 .init()
11 .unwrap();
12
13 let input = if let Ok(i) = aoc.get_input(false) {
14 i
15 } else {
16 "you probably need to add a valid cookie".to_string()
17 };
18
19 println!("{}", input);
20}
Sourcepub fn get_input(&mut self, force: bool) -> Result<String, Error>
pub fn get_input(&mut self, force: bool) -> Result<String, Error>
Get the input data
Examples found in repository?
examples/day01.rs (line 13)
5fn main() {
6 let mut aoc = Aoc::new()
7 .year(Some(2019))
8 .day(Some(1))
9 .cookie_file("./examples/cookie")
10 .init()
11 .unwrap();
12
13 let input = if let Ok(i) = aoc.get_input(false) {
14 i
15 } else {
16 "you probably need to add a valid cookie".to_string()
17 };
18
19 println!("{}", input);
20}
More examples
examples/day02.rs (line 13)
5fn main() {
6 let mut aoc = Aoc::new()
7 .year(Some(2019))
8 .day(Some(2))
9 .cookie("yoursessioncookiedatagoeshere")
10 .init()
11 .unwrap();
12
13 let input = if let Ok(i) = aoc.get_input(false) {
14 i
15 } else {
16 "you probably need to add a valid cookie".to_string()
17 };
18
19 println!("{}", input);
20}
Sourcepub fn from_json(json: &str) -> Result<Self, Error>
pub fn from_json(json: &str) -> Result<Self, Error>
get an AoC problem from JSON representation
Sourcepub fn write_json_to(&self, path: impl AsRef<Path>) -> Result<(), Error>
pub fn write_json_to(&self, path: impl AsRef<Path>) -> Result<(), Error>
Save problem to path as JSON
Sourcepub fn load_json_from(path: impl AsRef<Path>) -> Result<Self, Error>
pub fn load_json_from(path: impl AsRef<Path>) -> Result<Self, Error>
Load the problem from JSON
pub fn advance(&mut self) -> Result<(), Error>
Sourcepub fn get_time_until_release()
pub fn get_time_until_release()
Get time until release
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Aoc
impl<'de> Deserialize<'de> for Aoc
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Aoc
impl RefUnwindSafe for Aoc
impl Send for Aoc
impl Sync for Aoc
impl Unpin for Aoc
impl UnwindSafe for Aoc
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more