| Crates.io | get-full-year |
| lib.rs | get-full-year |
| version | 1.0.0 |
| created_at | 2025-01-03 02:29:18.542705+00 |
| updated_at | 2025-01-03 02:29:18.542705+00 |
| description | An unofficial Rust client for getfullyear.com that helps you get the full year. |
| homepage | |
| repository | https://github.com/mcnaveen/get-full-year-rs |
| max_upload_size | |
| id | 1502068 |
| size | 8,691 |
An unofficial Rust client for getfullyear.com that helps you get the full year. Because sometimes you just need to know what year it is, and you need to know it properly.
reqwest and tokioAdd the following to your Cargo.toml:
[dependencies]
get-full-year = "1.0.0"
use get_full_year::get_full_year;
#[tokio::main]
async fn main() {
match get_full_year(false).await {
Ok(data) => println!("Fetched Year Data: {:?}", data),
Err(e) => eprintln!("Error: {}", e),
}
}
use get_full_year_rs::get_full_year;
#[tokio::main]
async fn main() {
let is_enterprise = true; // Enterprise mode
match get_full_year(is_enterprise).await {
Ok(data) => println!("Enterprise Data: {:?}", data),
Err(e) => eprintln!("Error: {}", e),
}
}
get_full_year(is_enterprise: bool) -> Result<YearResponseDTO, Box<dyn Error>>
Makes a sophisticated request to getfullyear.com to fetch the current year data.
Parameters:
is_enterprise (required): bool
Returns:
Ok(YearResponseDTO): The current year data.Err(Box<dyn Error>): If an error occurs during the request.let data = get_full_year(false).await?;
println!("Year: {}", data.year);
pub struct YearResponseDTO {
pub year: u32,
pub sponsored_by: Option<String>,
pub metadata: Option<HashMap<String, serde_json::Value>>,
}
A custom error type that encapsulates errors occurring during the year-fetching process.
pub enum YearFetchingError {
RequestError(reqwest::Error),
JsonParsingError(serde_json::Error),
}
get-full-year-rs/
├── src/ # Source code
│ ├── dto.rs # Data structures
│ ├── errors.rs # Error handling
│ ├── services.rs # Business logic
│ └── lib.rs # Library entry point
├── Cargo.toml # Crate metadata
└── README.md # Documentation
Clone the repository and run the following command to install dependencies:
git clone https://github.com/yourusername/get-full-year-rs.git
cd get-full-year-rs
Build the project:
cargo build
Run the tests:
cargo test
Run the project:
cargo run
This project is licensed under the MIT License - see the LICENSE file for details.
Thanks to getfullyear.com for providing this essential service
The Rust community for making Rust awesome
The open-source community for continuous inspiration
Made with ❤️ and probably not coffee ☕️