#year #enterprise #fetching #rust

get-full-year

An unofficial Rust client for getfullyear.com that helps you get the full year

1 stable release

1.0.0 Jan 3, 2025

#529 in Data structures

Download history 111/week @ 2024-12-28 51/week @ 2025-01-04

162 downloads per month

MIT/Apache

8KB
59 lines

get-full-year 🦀

Crates.io
Docs.rs
License: MIT or Apache-2.0

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.


🚀 Features

  • Written in Rust with type safety
  • Async API powered by reqwest and tokio
  • Clean and simple design
  • Handles errors gracefully
  • Includes comprehensive documentation

📦 Installation

Add the following to your Cargo.toml:

[dependencies]
get-full-year = "1.0.0"

🔨 Usage

Basic Example

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),
    }
}

Enterprise Mode

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),
    }
}

🔍 API Reference

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
    • Enables enterprise mode, suppressing sponsorship messages.

Returns:

  • Ok(YearResponseDTO): The current year data.
  • Err(Box<dyn Error>): If an error occurs during the request.

Example

let data = get_full_year(false).await?;
println!("Year: {}", data.year);

Data Structure

  • YearResponseDTO
pub struct YearResponseDTO {
    pub year: u32,
    pub sponsored_by: Option<String>,
    pub metadata: Option<HashMap<String, serde_json::Value>>,
}
  • YearFetchingError

A custom error type that encapsulates errors occurring during the year-fetching process.

pub enum YearFetchingError {
    RequestError(reqwest::Error),
    JsonParsingError(serde_json::Error),
}

🏗️ Project Structure

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

🛠️ Development

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

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

👤 Author

🙏 Acknowledgments

  • Thanks to getfullyear.com for providing this essential service
  • The Rust community for making Rust awesome
  • The open-source community for continuous inspiration

📊 Stats

GitHub stars crates.io


Made with ❤️ and probably not coffee ☕️

Dependencies

~7–19MB
~258K SLoC