1use ratatui_core::text::Text;
2
3pub trait KnownSize {
13 fn width(&self) -> usize;
14 fn height(&self) -> usize;
15}
16
17impl KnownSize for Text<'_> {
18 fn width(&self) -> usize {
19 self.width()
20 }
21
22 fn height(&self) -> usize {
23 self.height()
24 }
25}
26
27impl KnownSize for &Text<'_> {
28 fn width(&self) -> usize {
29 Text::width(self)
30 }
31
32 fn height(&self) -> usize {
33 Text::height(self)
34 }
35}
36
37impl KnownSize for &str {
38 fn width(&self) -> usize {
39 Text::from(*self).width()
40 }
41
42 fn height(&self) -> usize {
43 Text::from(*self).height()
44 }
45}
46
47impl KnownSize for String {
48 fn width(&self) -> usize {
49 Text::from(self.as_str()).width()
50 }
51
52 fn height(&self) -> usize {
53 Text::from(self.as_str()).height()
54 }
55}