1#![allow(clippy::cast_possible_truncation)]
2#![allow(clippy::cast_precision_loss)]
3#![allow(clippy::cast_lossless)]
4#![allow(clippy::too_many_lines)]
5#![allow(clippy::module_name_repetitions)]
6#![allow(clippy::similar_names)]
7
8pub mod angle;
29pub mod config;
31pub mod direction;
33pub mod distance;
35pub mod humidity;
37pub mod latitude;
39pub mod longitude;
41pub mod precipitation;
43pub mod pressure;
45pub mod speed;
47pub mod temperature;
49pub mod timestamp;
51pub mod timezone;
53pub mod weather_api;
55pub mod weather_data;
57pub mod weather_forecast;
59pub mod weather_opts;
61
62pub mod error;
64
65pub use error::Error;
66use time::{OffsetDateTime, macros::datetime};
67
68#[must_use]
69pub fn default_datetime() -> OffsetDateTime {
70 datetime!(1970-01-01 00:00:00).assume_utc()
71}
72
73#[cfg(feature = "stackstring")]
74use stack_string::{SmallString, StackString};
75#[cfg(feature = "stackstring")]
76pub type StringType = StackString;
77#[cfg(feature = "stackstring")]
78pub type ApiStringType = SmallString<32>;
79
80#[cfg(feature = "stackstring")]
81pub fn apistringtype_from_display(buf: impl std::fmt::Display) -> ApiStringType {
82 SmallString::from_display(buf)
83}
84
85#[cfg(not(feature = "stackstring"))]
86pub type StringType = String;
87#[cfg(not(feature = "stackstring"))]
88pub type ApiStringType = String;
89
90#[cfg(not(feature = "stackstring"))]
91pub fn apistringtype_from_display(buf: impl std::fmt::Display) -> ApiStringType {
92 format!("{buf}")
93}
94
95#[cfg(feature = "stackstring")]
96#[macro_export]
97macro_rules! format_string {
98 ($($arg:tt)*) => {
99 {
100 use std::fmt::Write;
101 let mut buf = stack_string::StackString::new();
102 std::write!(buf, "{}", std::format_args!($($arg)*)).unwrap();
103 buf
104 }
105 };
106}
107
108#[cfg(not(feature = "stackstring"))]
109#[macro_export]
110macro_rules! format_string {
111 ($($arg:tt)*) => {
112 {
113 use std::fmt::Write;
114 let mut buf = String::new();
115 std::write!(buf, "{}", std::format_args!($($arg)*)).unwrap();
116 buf
117 }
118 };
119}