Crates.io | aoc_api |
lib.rs | aoc_api |
version | 1.1.0 |
source | src |
created_at | 2024-07-29 18:39:57.00214 |
updated_at | 2024-07-31 06:18:07.76969 |
description | a simple Advent of Code API |
homepage | |
repository | https://github.com/antoniosubasic/aoc_api |
max_upload_size | |
id | 1319101 |
size | 52,081 |
a simple Advent of Code API written in Rust - also checkout the C# version
cargo add aoc_api
use aoc_api::Session;
let client = Session::new("session cookie": String, year: u16, day: u8); // Initializes a new Session instance
let client = Session::new("session cookie": String, input: String, pattern: Regex); // Initializes a new Session instance
The Regex overload needs to have a regex group named "year" and a group named "day".
How to name Regex groups
How to obtain session cookie
let input_text: Result<String, Box<dyn Error>> = client.get_input_text().await; // Retrieves the input text of the AoC puzzle
let input_lines: Result<Vec<String>, Box<dyn Error>> = client.get_input_lines().await; // Retrieves the input lines of the AoC puzzle
let sample_input_text: Result<String, Box<dyn Error>> = client.get_sample_input_text(nth: u8).await; // Retrieves the nth sample input text of the AoC puzzle
let sample_input_lines: Result<Vec<String>, Box<dyn Error>> = client.get_sample_input_lines(nth: u8).await; // Retrieves the nth sample input lines of the AoC puzzle
let achieved_stars: Result<HashMap<u16, u8>, Box<dyn Error>> = client.get_all_stars().await; // Retrieves each year's number of stars earned (key: year, value: stars)
let response: Result<Response, Box<dyn Error>> = client.submit_answer(part: u8, answer: &str).await; // Submits an answer to part 1 or 2 of the AoC puzzle. Returns a response type with a success status and a cooldown period
credits to:
Max - markdown info icons
Monday Morning Haskell - documentation on how to obtaining session cookie
Developer.Mozilla - documentation on how to name Regex groups