#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(feature = "simd", feature(portable_simd))]
#![cfg_attr(not(feature = "std"), no_std)]
#![deny(nonstandard_style, missing_copy_implementations, missing_docs)]
#![forbid(unsafe_code)]
#![allow(clippy::large_enum_variant, clippy::enum_variant_names)]
#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/167914012")]
#![doc(html_favicon_url = "https://avatars.githubusercontent.com/u/167914012")]
#[cfg(not(feature = "std"))]
extern crate alloc;
#[cfg(feature = "std")]
extern crate std;
use core::{fmt, fmt::Debug, write};
mod delta;
mod window;
pub mod aggregator;
pub mod duration;
pub mod wheels;
pub use delta::DeltaState;
pub use duration::{Duration, NumericalDuration};
#[macro_use]
#[doc(hidden)]
mod macros;
pub use aggregator::Aggregator;
pub use wheels::{
Conf,
RwWheel,
read::{
aggregation::conf::{CompressionPolicy, RetentionPolicy, WheelConf},
hierarchical::{Haw, HawConf, WheelRange},
},
};
pub use window::{Window, WindowAggregate};
#[doc(hidden)]
pub use time::OffsetDateTime;
#[doc(hidden)]
pub use wheels::read::{DAYS, HOURS, MINUTES, SECONDS, WEEKS, YEARS};
#[repr(C)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[derive(Debug, Copy, Clone)]
pub struct Entry<T: Debug> {
pub data: T,
pub timestamp: u64,
}
impl<T: Debug> Entry<T> {
pub fn new(data: T, timestamp: u64) -> Self {
Self { data, timestamp }
}
}
impl<T: Debug> fmt::Display for Entry<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "(data: {:?}, timestamp: {})", self.data, self.timestamp)
}
}
impl<T: Debug> From<(T, u64)> for Entry<T> {
fn from(val: (T, u64)) -> Self {
Entry::new(val.0, val.1)
}
}
#[doc(hidden)]
#[macro_export]
macro_rules! capacity_to_slots {
($cap:tt) => {
if $cap.get().is_power_of_two() {
$cap.get()
} else {
$cap.get().next_power_of_two()
}
};
}