Struct Aoc

Source
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

Source

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
Hide additional 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}
Source

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
Hide additional 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}
Source

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
Hide additional 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}
Source

pub fn cookie(self, cookie: &str) -> Self

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}
Source

pub fn cookie_file(self, path: impl AsRef<Path>) -> Self

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}
Source

pub fn cache<P>(self, path: Option<&Path>) -> Self

Set the cache path

Source

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.

Source

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
Hide additional 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}
Source

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
Hide additional 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}
Source

pub fn to_json(&self) -> Result<String, Error>

get a JSON representation for the AoC problem

Source

pub fn from_json(json: &str) -> Result<Self, Error>

get an AoC problem from JSON representation

Source

pub fn write_json_to(&self, path: impl AsRef<Path>) -> Result<(), Error>

Save problem to path as JSON

Source

pub fn load_json_from(path: impl AsRef<Path>) -> Result<Self, Error>

Load the problem from JSON

Source

pub fn write(&self) -> Result<(), Error>

Write JSON cache

Source

pub fn advance(&mut self) -> Result<(), Error>

Source

pub fn get_time_until_release()

Get time until release

Trait Implementations§

Source§

impl Clone for Aoc

Source§

fn clone(&self) -> Aoc

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Aoc

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Aoc

Source§

fn default() -> Aoc

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Aoc

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Aoc

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,