tabled/settings/panel/
footer.rs

1use crate::{
2    grid::config::ColoredConfig,
3    grid::records::{ExactRecords, Records, RecordsMut, Resizable},
4    settings::TableOption,
5};
6
7use super::Panel;
8
9/// Footer renders a [`Panel`] at the bottom.
10/// See [`Panel`].
11#[derive(Debug)]
12pub struct Footer<S>(S);
13
14impl<S> Footer<S> {
15    /// Creates a new object.
16    pub fn new(text: S) -> Self
17    where
18        S: AsRef<str>,
19    {
20        Self(text)
21    }
22}
23
24impl<S, R, D> TableOption<R, ColoredConfig, D> for Footer<S>
25where
26    S: AsRef<str>,
27    R: Records + ExactRecords + Resizable + RecordsMut<String>,
28{
29    fn change(self, records: &mut R, cfg: &mut ColoredConfig, dimension: &mut D) {
30        Panel::horizontal(records.count_rows(), self.0.as_ref()).change(records, cfg, dimension);
31    }
32}