global: snapshot

This commit is contained in:
nym21
2026-03-10 01:13:52 +01:00
parent 961dea6934
commit 46ac55d950
121 changed files with 9792 additions and 5997 deletions

View File

@@ -1,7 +1,13 @@
mod distribution_stats;
mod per_resolution;
mod window_24h;
mod windows;
mod windows_except_1m;
mod windows_from_1w;
pub use distribution_stats::*;
pub use per_resolution::*;
pub use window_24h::*;
pub use windows::*;
pub use windows_except_1m::*;
pub use windows_from_1w::*;

View File

@@ -0,0 +1,7 @@
use brk_traversable::Traversable;
/// Generic single-24h-window container.
#[derive(Traversable)]
pub struct RollingWindow24h<Inner> {
pub _24h: Inner,
}

View File

@@ -0,0 +1,30 @@
use brk_traversable::Traversable;
#[derive(Clone, Traversable)]
pub struct WindowsExcept1m<A> {
pub _24h: A,
pub _1w: A,
pub _1y: A,
}
impl<A> WindowsExcept1m<A> {
pub const SUFFIXES: [&'static str; 3] = ["24h", "1w", "1y"];
pub fn try_from_fn<E>(
mut f: impl FnMut(&str) -> std::result::Result<A, E>,
) -> std::result::Result<Self, E> {
Ok(Self {
_24h: f(Self::SUFFIXES[0])?,
_1w: f(Self::SUFFIXES[1])?,
_1y: f(Self::SUFFIXES[2])?,
})
}
pub fn as_array(&self) -> [&A; 3] {
[&self._24h, &self._1w, &self._1y]
}
pub fn as_mut_array(&mut self) -> [&mut A; 3] {
[&mut self._24h, &mut self._1w, &mut self._1y]
}
}

View File

@@ -0,0 +1,30 @@
use brk_traversable::Traversable;
#[derive(Clone, Traversable)]
pub struct WindowsFrom1w<A> {
pub _1w: A,
pub _1m: A,
pub _1y: A,
}
impl<A> WindowsFrom1w<A> {
pub const SUFFIXES: [&'static str; 3] = ["1w", "1m", "1y"];
pub fn try_from_fn<E>(
mut f: impl FnMut(&str) -> std::result::Result<A, E>,
) -> std::result::Result<Self, E> {
Ok(Self {
_1w: f(Self::SUFFIXES[0])?,
_1m: f(Self::SUFFIXES[1])?,
_1y: f(Self::SUFFIXES[2])?,
})
}
pub fn as_array(&self) -> [&A; 3] {
[&self._1w, &self._1m, &self._1y]
}
pub fn as_mut_array(&mut self) -> [&mut A; 3] {
[&mut self._1w, &mut self._1m, &mut self._1y]
}
}