1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! An empty [`Records`] implementation.

use crate::{records::Records, Position};

/// Empty representation of [`Records`].
#[derive(Debug, Default, Clone)]
pub struct EmptyRecords {
    rows: usize,
    cols: usize,
}

impl EmptyRecords {
    /// Constracts an empty representation of [`Records`] with a given shape.
    pub fn new(rows: usize, cols: usize) -> Self {
        Self { rows, cols }
    }
}

impl Records for EmptyRecords {
    fn count_rows(&self) -> usize {
        self.rows
    }

    fn count_columns(&self) -> usize {
        self.cols
    }

    fn get_text(&self, _: Position) -> &str {
        ""
    }

    fn get_line(&self, _: Position, _: usize) -> &str {
        ""
    }

    fn get_width<W>(&self, _: Position, _: W) -> usize {
        0
    }

    fn get_line_width<W>(&self, _: Position, _: usize, _: W) -> usize {
        0
    }

    fn count_lines(&self, _: Position) -> usize {
        1
    }

    fn fmt_text_prefix(&self, _: &mut std::fmt::Formatter<'_>, _: Position) -> std::fmt::Result {
        Ok(())
    }

    fn fmt_text_suffix(&self, _: &mut std::fmt::Formatter<'_>, _: Position) -> std::fmt::Result {
        Ok(())
    }
}