1//! The module contains an [`Dimension`] trait and its implementations.
2
3#[cfg(feature = "std")]
4pub mod compact;
5#[cfg(feature = "std")]
6pub mod spanned;
7#[cfg(feature = "std")]
8pub mod spanned_vec_records;
9
10/// Dimension of a [`Grid`]
11///
12/// It's a friend trait of [`Estimate`].
13///
14/// [`Grid`]: crate::grid::iterable::Grid
15pub trait Dimension {
16 /// Get a column width by index.
17 fn get_width(&self, column: usize) -> usize;
18
19 /// Get a row height by index.
20 fn get_height(&self, row: usize) -> usize;
21}
22
23impl<T> Dimension for &T
24where
25 T: Dimension,
26{
27 fn get_height(&self, row: usize) -> usize {
28 T::get_height(self, row)
29 }
30
31 fn get_width(&self, column: usize) -> usize {
32 T::get_width(self, column)
33 }
34}
35
36/// Dimension estimation of a [`Grid`]
37///
38/// It's a friend trait of [`Dimension`].
39///
40/// [`Grid`]: crate::grid::iterable::Grid
41pub trait Estimate<R, C> {
42 /// Estimates a metric.
43 fn estimate(&mut self, records: R, config: &C);
44}
45