Add module src/free_api_v25/current/clouds.rs
This commit is contained in:
parent
32a94af1ee
commit
bbec51dbe6
23
src/free_api_v25/current/clouds.rs
Normal file
23
src/free_api_v25/current/clouds.rs
Normal file
@ -0,0 +1,23 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Cloud cover information
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, Default, PartialEq)]
|
||||
pub struct Clouds {
|
||||
/// Cloudiness percentage (0-100)
|
||||
#[serde(default)]
|
||||
pub all: Option<u8>,
|
||||
}
|
||||
|
||||
impl Clouds {
|
||||
/// Returns true if cloud cover indicates clear skies (<= 20%)
|
||||
#[must_use]
|
||||
pub fn is_clear(&self) -> bool {
|
||||
self.all.is_some_and(|cover| cover <= 20)
|
||||
}
|
||||
|
||||
/// Returns true if cloud cover indicates overcast (>= 80%)
|
||||
#[must_use]
|
||||
pub fn is_overcast(&self) -> bool {
|
||||
self.all.is_some_and(|cover| cover >= 80)
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@
|
||||
//! - [`forecast`](crate::forecast) for multi-day weather data
|
||||
//! - [`query`](crate::query) for building request URLs
|
||||
|
||||
pub mod clouds;
|
||||
pub mod coord;
|
||||
pub mod main;
|
||||
pub mod weather;
|
||||
|
Loading…
x
Reference in New Issue
Block a user