Frame

Struct Frame 

Source
pub struct Frame<'a> { /* private fields */ }
Expand description

A consistent view into the terminal state for rendering a single frame.

This is obtained via the closure argument of Terminal::draw. It is used to render widgets to the terminal and control the cursor position.

The changes drawn to the frame are applied only to the current Buffer. After the closure returns, the current buffer is compared to the previous buffer and only the changes are applied to the terminal. This avoids drawing redundant cells.

Implementations§

Source§

impl Frame<'_>

Source

pub const fn area(&self) -> Rect

The area of the current frame

This is guaranteed not to change during rendering, so may be called multiple times.

If your app listens for a resize event from the backend, it should ignore the values from the event for any calculations that are used to render the current frame and use this value instead as this is the area of the buffer that is used to render the current frame.

Examples found in repository?
examples/basic_gradient.rs (line 53)
24fn run(
25    terminal: &mut ratatui::DefaultTerminal,
26    set: SegmentSet,
27) -> io::Result<()> {
28    use tui_gradient_block::gradient_block::GradientBlock;
29    let block = GradientBlock::new()
30        .with_set(set)
31        .left_gradient(solid((48, 174, 209)))
32        .bottom_gradient(solid((48, 174, 209)))
33        .top_gradient(Box::new(
34            GradientBuilder::new()
35                .colors(&[
36                    Color::from_rgba8(48, 174, 209, 1),
37                    Color::from_rgba8(225, 22, 247, 1),
38                ])
39                .build::<colorgrad::LinearGradient>()
40                .unwrap(),
41        ))
42        .right_gradient(Box::new(
43            GradientBuilder::new()
44                .colors(&[
45                    Color::from_rgba8(225, 22, 247, 1),
46                    Color::from_rgba8(48, 174, 209, 1),
47                ])
48                .build::<colorgrad::LinearGradient>()
49                .unwrap(),
50        ));
51
52    loop {
53        terminal.draw(|f| f.render_widget(&block, f.area()))?;
54        let event = event::read()?;
55
56        if let Event::Key(key_event) = event {
57            if key_event.kind == KeyEventKind::Press {
58                if let KeyCode::Char('q') = key_event.code {
59                    break Ok(());
60                }
61            }
62        }
63    }
64}
More examples
Hide additional examples
examples/themes/zombie_dreams.rs (line 50)
15fn run(
16    terminal: &mut ratatui::DefaultTerminal,
17    set: SegmentSet,
18) -> io::Result<()> {
19    use ratatui::{text::Line, layout::{Constraint, Direction, Layout}};
20    use tui_gradient_block::{
21        gradient_block::GradientBlock,
22        theme_presets::cool::t_zombie_dreams,
23    };
24    let theme = t_zombie_dreams::full();
25    let blocks = vec![
26        GradientBlock::new()
27            .with_gradient(theme.double_corners_left)
28            .with_set(set.clone()),
29        GradientBlock::new().title_top(Line::from(tui_rule::generate_gradient_text!("Zombie Dreams", theme.right.top)).centered())
30            .with_gradient(theme.misc1)
31            .with_set(set.clone()),
32        GradientBlock::new()
33            .with_gradient(theme.double_corners_right)
34            .with_set(set.clone()),
35    ];
36
37    loop {
38        terminal.draw(|f| {
39            let base = Layout::new(
40                Direction::Horizontal,
41                [
42                    Constraint::Percentage(33),
43                    Constraint::Percentage(33),
44                    Constraint::Percentage(34),
45                ],
46            )
47            .vertical_margin(1)
48            .horizontal_margin(1)
49            .spacing(3)
50            .split(f.area());
51            for (block, area) in blocks.iter().zip(base.iter()) {
52                f.render_widget(block, *area);
53            }
54        })?;
55        let event = event::read()?;
56
57        if let Event::Key(key_event) = event {
58            if key_event.kind == KeyEventKind::Press {
59                if let KeyCode::Char('q') = key_event.code {
60                    break Ok(());
61                }
62            }
63        }
64    }
65}
examples/themes/misty_blue.rs (line 101)
14fn run(
15    terminal: &mut ratatui::DefaultTerminal,
16    set: SegmentSet,
17) -> io::Result<()> {
18    use ratatui::layout::{Constraint, Direction, Layout};
19    use tui_gradient_block::{
20        gradient_block::GradientBlock,
21        theme_presets::cool::t_misty_blue,
22    };
23    let titles = t_misty_blue::titles();
24    let theme = t_misty_blue::full();
25    let blocks_top = vec![
26        GradientBlock::new()
27            .title(titles.up.0, titles.up.1)
28            .with_gradient(theme.up)
29            .with_set(set.clone()),
30        GradientBlock::new()
31            .title(titles.down.0, titles.down.1)
32            .with_gradient(theme.down)
33            .with_set(set.clone()),
34        GradientBlock::new()
35            .title(titles.left.0, titles.left.1)
36            .with_gradient(theme.left)
37            .with_set(set.clone()),
38        GradientBlock::new()
39            .title(titles.right.0, titles.right.1)
40            .with_gradient(theme.right)
41            .with_set(set.clone()),
42        GradientBlock::new()
43            .title(titles.top_left.0, titles.top_left.1)
44            .with_gradient(theme.top_left)
45            .with_set(set.clone()),
46        GradientBlock::new()
47            .title(titles.top_right.0, titles.top_right.1)
48            .with_gradient(theme.top_right)
49            .with_set(set.clone()),
50        GradientBlock::new()
51            .title(titles.bottom_left.0, titles.bottom_left.1)
52            .with_gradient(theme.bottom_left)
53            .with_set(set.clone()),
54    ];
55    let blocks_bottom = vec![
56        GradientBlock::new()
57            .title(titles.bottom_right.0, titles.bottom_right.1)
58            .with_gradient(theme.bottom_right)
59            .with_set(set.clone()),
60        GradientBlock::new()
61            .title(
62                titles.double_corners_left.0,
63                titles.double_corners_left.1,
64            )
65            .with_gradient(theme.double_corners_left)
66            .with_set(set.clone()),
67        GradientBlock::new()
68            .title(
69                titles.double_corners_right.0,
70                titles.double_corners_right.1,
71            )
72            .with_gradient(theme.double_corners_right)
73            .with_set(set.clone()),
74        GradientBlock::new()
75            .title(titles.vertical.0, titles.vertical.1)
76            .with_gradient(theme.vertical)
77            .with_set(set.clone()),
78        GradientBlock::new()
79            .title(titles.horizontal.0, titles.horizontal.1)
80            .with_gradient(theme.horizontal)
81            .with_set(set.clone()),
82        GradientBlock::new()
83            .title(titles.misc1.0, titles.misc1.1)
84            .with_gradient(theme.misc1)
85            .with_set(set.clone()),
86        GradientBlock::new()
87            .title(titles.misc2.0, titles.misc2.1)
88            .with_gradient(theme.misc2)
89            .with_set(set.clone()),
90    ];
91
92    loop {
93        terminal.draw(|f| {
94            let base = Layout::new(
95                Direction::Vertical,
96                [
97                    Constraint::Percentage(50),
98                    Constraint::Percentage(50),
99                ],
100            )
101            .split(f.area());
102            let top = Layout::new(
103                Direction::Horizontal,
104                [
105                    Constraint::Percentage(14),
106                    Constraint::Percentage(14),
107                    Constraint::Percentage(14),
108                    Constraint::Percentage(14),
109                    Constraint::Percentage(14),
110                    Constraint::Percentage(15),
111                    Constraint::Percentage(15),
112                ],
113            )
114            .split(base[0]);
115            let bottom = Layout::new(
116                Direction::Horizontal,
117                [
118                    Constraint::Percentage(14),
119                    Constraint::Percentage(14),
120                    Constraint::Percentage(14),
121                    Constraint::Percentage(14),
122                    Constraint::Percentage(14),
123                    Constraint::Percentage(15),
124                    Constraint::Percentage(15),
125                ],
126            )
127            .split(base[1]);
128            for (block, area) in blocks_top.iter().zip(top.iter()) {
129                f.render_widget(block, *area);
130            }
131            for (block, area) in
132                blocks_bottom.iter().zip(bottom.iter())
133            {
134                f.render_widget(block, *area);
135            }
136        })?;
137        let event = event::read()?;
138
139        if let Event::Key(key_event) = event {
140            if key_event.kind == KeyEventKind::Press {
141                if let KeyCode::Char('q') = key_event.code {
142                    break Ok(());
143                }
144            }
145        }
146    }
147}
examples/themes/monochrome.rs (line 101)
14fn run(
15    terminal: &mut ratatui::DefaultTerminal,
16    set: SegmentSet,
17) -> io::Result<()> {
18    use ratatui::layout::{Constraint, Direction, Layout};
19    use tui_gradient_block::{
20        gradient_block::GradientBlock,
21        theme_presets::misc::t_monochrome,
22    };
23    let titles = t_monochrome::titles();
24    let theme = t_monochrome::full();
25    let blocks_top = vec![
26        GradientBlock::new()
27            .title(titles.up.0, titles.up.1)
28            .with_gradient(theme.up)
29            .with_set(set.clone()),
30        GradientBlock::new()
31            .title(titles.down.0, titles.down.1)
32            .with_gradient(theme.down)
33            .with_set(set.clone()),
34        GradientBlock::new()
35            .title(titles.left.0, titles.left.1)
36            .with_gradient(theme.left)
37            .with_set(set.clone()),
38        GradientBlock::new()
39            .title(titles.right.0, titles.right.1)
40            .with_gradient(theme.right)
41            .with_set(set.clone()),
42        GradientBlock::new()
43            .title(titles.top_left.0, titles.top_left.1)
44            .with_gradient(theme.top_left)
45            .with_set(set.clone()),
46        GradientBlock::new()
47            .title(titles.top_right.0, titles.top_right.1)
48            .with_gradient(theme.top_right)
49            .with_set(set.clone()),
50        GradientBlock::new()
51            .title(titles.bottom_left.0, titles.bottom_left.1)
52            .with_gradient(theme.bottom_left)
53            .with_set(set.clone()),
54    ];
55    let blocks_bottom = vec![
56        GradientBlock::new()
57            .title(titles.bottom_right.0, titles.bottom_right.1)
58            .with_gradient(theme.bottom_right)
59            .with_set(set.clone()),
60        GradientBlock::new()
61            .title(
62                titles.double_corners_left.0,
63                titles.double_corners_left.1,
64            )
65            .with_gradient(theme.double_corners_left)
66            .with_set(set.clone()),
67        GradientBlock::new()
68            .title(
69                titles.double_corners_right.0,
70                titles.double_corners_right.1,
71            )
72            .with_gradient(theme.double_corners_right)
73            .with_set(set.clone()),
74        GradientBlock::new()
75            .title(titles.vertical.0, titles.vertical.1)
76            .with_gradient(theme.vertical)
77            .with_set(set.clone()),
78        GradientBlock::new()
79            .title(titles.horizontal.0, titles.horizontal.1)
80            .with_gradient(theme.horizontal)
81            .with_set(set.clone()),
82        GradientBlock::new()
83            .title(titles.misc1.0, titles.misc1.1)
84            .with_gradient(theme.misc1)
85            .with_set(set.clone()),
86        GradientBlock::new()
87            .title(titles.misc2.0, titles.misc2.1)
88            .with_gradient(theme.misc2)
89            .with_set(set.clone()),
90    ];
91
92    loop {
93        terminal.draw(|f| {
94            let base = Layout::new(
95                Direction::Vertical,
96                [
97                    Constraint::Percentage(50),
98                    Constraint::Percentage(50),
99                ],
100            )
101            .split(f.area());
102            let top = Layout::new(
103                Direction::Horizontal,
104                [
105                    Constraint::Percentage(14),
106                    Constraint::Percentage(14),
107                    Constraint::Percentage(14),
108                    Constraint::Percentage(14),
109                    Constraint::Percentage(14),
110                    Constraint::Percentage(15),
111                    Constraint::Percentage(15),
112                ],
113            )
114            .split(base[0]);
115            let bottom = Layout::new(
116                Direction::Horizontal,
117                [
118                    Constraint::Percentage(14),
119                    Constraint::Percentage(14),
120                    Constraint::Percentage(14),
121                    Constraint::Percentage(14),
122                    Constraint::Percentage(14),
123                    Constraint::Percentage(15),
124                    Constraint::Percentage(15),
125                ],
126            )
127            .split(base[1]);
128            for (block, area) in blocks_top.iter().zip(top.iter()) {
129                f.render_widget(block, *area);
130            }
131            for (block, area) in
132                blocks_bottom.iter().zip(bottom.iter())
133            {
134                f.render_widget(block, *area);
135            }
136        })?;
137        let event = event::read()?;
138
139        if let Event::Key(key_event) = event {
140            if key_event.kind == KeyEventKind::Press {
141                if let KeyCode::Char('q') = key_event.code {
142                    break Ok(());
143                }
144            }
145        }
146    }
147}
examples/themes/minty_green.rs (line 101)
14fn run(
15    terminal: &mut ratatui::DefaultTerminal,
16    set: SegmentSet,
17) -> io::Result<()> {
18    use ratatui::layout::{Constraint, Direction, Layout};
19    use tui_gradient_block::{
20        gradient_block::GradientBlock,
21        theme_presets::cool::t_minty_green,
22    };
23    let titles = t_minty_green::titles();
24    let theme = t_minty_green::full();
25    let blocks_top = vec![
26        GradientBlock::new()
27            .title(titles.up.0, titles.up.1)
28            .with_gradient(theme.up)
29            .with_set(set.clone()),
30        GradientBlock::new()
31            .title(titles.down.0, titles.down.1)
32            .with_gradient(theme.down)
33            .with_set(set.clone()),
34        GradientBlock::new()
35            .title(titles.left.0, titles.left.1)
36            .with_gradient(theme.left)
37            .with_set(set.clone()),
38        GradientBlock::new()
39            .title(titles.right.0, titles.right.1)
40            .with_gradient(theme.right)
41            .with_set(set.clone()),
42        GradientBlock::new()
43            .title(titles.top_left.0, titles.top_left.1)
44            .with_gradient(theme.top_left)
45            .with_set(set.clone()),
46        GradientBlock::new()
47            .title(titles.top_right.0, titles.top_right.1)
48            .with_gradient(theme.top_right)
49            .with_set(set.clone()),
50        GradientBlock::new()
51            .title(titles.bottom_left.0, titles.bottom_left.1)
52            .with_gradient(theme.bottom_left)
53            .with_set(set.clone()),
54    ];
55    let blocks_bottom = vec![
56        GradientBlock::new()
57            .title(titles.bottom_right.0, titles.bottom_right.1)
58            .with_gradient(theme.bottom_right)
59            .with_set(set.clone()),
60        GradientBlock::new()
61            .title(
62                titles.double_corners_left.0,
63                titles.double_corners_left.1,
64            )
65            .with_gradient(theme.double_corners_left)
66            .with_set(set.clone()),
67        GradientBlock::new()
68            .title(
69                titles.double_corners_right.0,
70                titles.double_corners_right.1,
71            )
72            .with_gradient(theme.double_corners_right)
73            .with_set(set.clone()),
74        GradientBlock::new()
75            .title(titles.vertical.0, titles.vertical.1)
76            .with_gradient(theme.vertical)
77            .with_set(set.clone()),
78        GradientBlock::new()
79            .title(titles.horizontal.0, titles.horizontal.1)
80            .with_gradient(theme.horizontal)
81            .with_set(set.clone()),
82        GradientBlock::new()
83            .title(titles.misc1.0, titles.misc1.1)
84            .with_gradient(theme.misc1)
85            .with_set(set.clone()),
86        GradientBlock::new()
87            .title(titles.misc2.0, titles.misc2.1)
88            .with_gradient(theme.misc2)
89            .with_set(set.clone()),
90    ];
91
92    loop {
93        terminal.draw(|f| {
94            let base = Layout::new(
95                Direction::Vertical,
96                [
97                    Constraint::Percentage(50),
98                    Constraint::Percentage(50),
99                ],
100            )
101            .split(f.area());
102            let top = Layout::new(
103                Direction::Horizontal,
104                [
105                    Constraint::Percentage(14),
106                    Constraint::Percentage(14),
107                    Constraint::Percentage(14),
108                    Constraint::Percentage(14),
109                    Constraint::Percentage(14),
110                    Constraint::Percentage(15),
111                    Constraint::Percentage(15),
112                ],
113            )
114            .split(base[0]);
115            let bottom = Layout::new(
116                Direction::Horizontal,
117                [
118                    Constraint::Percentage(14),
119                    Constraint::Percentage(14),
120                    Constraint::Percentage(14),
121                    Constraint::Percentage(14),
122                    Constraint::Percentage(14),
123                    Constraint::Percentage(15),
124                    Constraint::Percentage(15),
125                ],
126            )
127            .split(base[1]);
128            for (block, area) in blocks_top.iter().zip(top.iter()) {
129                f.render_widget(block, *area);
130            }
131            for (block, area) in
132                blocks_bottom.iter().zip(bottom.iter())
133            {
134                f.render_widget(block, *area);
135            }
136        })?;
137        let event = event::read()?;
138
139        if let Event::Key(key_event) = event {
140            if key_event.kind == KeyEventKind::Press {
141                if let KeyCode::Char('q') = key_event.code {
142                    break Ok(());
143                }
144            }
145        }
146    }
147}
examples/themes/rusty_ruins.rs (line 101)
14fn run(
15    terminal: &mut ratatui::DefaultTerminal,
16    set: SegmentSet,
17) -> io::Result<()> {
18    use ratatui::layout::{Constraint, Direction, Layout};
19    use tui_gradient_block::{
20        gradient_block::GradientBlock,
21        theme_presets::warm::t_rusty_ruins,
22    };
23    let titles = t_rusty_ruins::titles();
24    let theme = t_rusty_ruins::full();
25    let blocks_top = vec![
26        GradientBlock::new()
27            .title(titles.up.0, titles.up.1)
28            .with_gradient(theme.up)
29            .with_set(set.clone()),
30        GradientBlock::new()
31            .title(titles.down.0, titles.down.1)
32            .with_gradient(theme.down)
33            .with_set(set.clone()),
34        GradientBlock::new()
35            .title(titles.left.0, titles.left.1)
36            .with_gradient(theme.left)
37            .with_set(set.clone()),
38        GradientBlock::new()
39            .title(titles.right.0, titles.right.1)
40            .with_gradient(theme.right)
41            .with_set(set.clone()),
42        GradientBlock::new()
43            .title(titles.top_left.0, titles.top_left.1)
44            .with_gradient(theme.top_left)
45            .with_set(set.clone()),
46        GradientBlock::new()
47            .title(titles.top_right.0, titles.top_right.1)
48            .with_gradient(theme.top_right)
49            .with_set(set.clone()),
50        GradientBlock::new()
51            .title(titles.bottom_left.0, titles.bottom_left.1)
52            .with_gradient(theme.bottom_left)
53            .with_set(set.clone()),
54    ];
55    let blocks_bottom = vec![
56        GradientBlock::new()
57            .title(titles.bottom_right.0, titles.bottom_right.1)
58            .with_gradient(theme.bottom_right)
59            .with_set(set.clone()),
60        GradientBlock::new()
61            .title(
62                titles.double_corners_left.0,
63                titles.double_corners_left.1,
64            )
65            .with_gradient(theme.double_corners_left)
66            .with_set(set.clone()),
67        GradientBlock::new()
68            .title(
69                titles.double_corners_right.0,
70                titles.double_corners_right.1,
71            )
72            .with_gradient(theme.double_corners_right)
73            .with_set(set.clone()),
74        GradientBlock::new()
75            .title(titles.vertical.0, titles.vertical.1)
76            .with_gradient(theme.vertical)
77            .with_set(set.clone()),
78        GradientBlock::new()
79            .title(titles.horizontal.0, titles.horizontal.1)
80            .with_gradient(theme.horizontal)
81            .with_set(set.clone()),
82        GradientBlock::new()
83            .title(titles.misc1.0, titles.misc1.1)
84            .with_gradient(theme.misc1)
85            .with_set(set.clone()),
86        GradientBlock::new()
87            .title(titles.misc2.0, titles.misc2.1)
88            .with_gradient(theme.misc2)
89            .with_set(set.clone()),
90    ];
91
92    loop {
93        terminal.draw(|f| {
94            let base = Layout::new(
95                Direction::Vertical,
96                [
97                    Constraint::Percentage(50),
98                    Constraint::Percentage(50),
99                ],
100            )
101            .split(f.area());
102            let top = Layout::new(
103                Direction::Horizontal,
104                [
105                    Constraint::Percentage(14),
106                    Constraint::Percentage(14),
107                    Constraint::Percentage(14),
108                    Constraint::Percentage(14),
109                    Constraint::Percentage(14),
110                    Constraint::Percentage(15),
111                    Constraint::Percentage(15),
112                ],
113            )
114            .split(base[0]);
115            let bottom = Layout::new(
116                Direction::Horizontal,
117                [
118                    Constraint::Percentage(14),
119                    Constraint::Percentage(14),
120                    Constraint::Percentage(14),
121                    Constraint::Percentage(14),
122                    Constraint::Percentage(14),
123                    Constraint::Percentage(15),
124                    Constraint::Percentage(15),
125                ],
126            )
127            .split(base[1]);
128            for (block, area) in blocks_top.iter().zip(top.iter()) {
129                f.render_widget(block, *area);
130            }
131            for (block, area) in
132                blocks_bottom.iter().zip(bottom.iter())
133            {
134                f.render_widget(block, *area);
135            }
136        })?;
137        let event = event::read()?;
138
139        if let Event::Key(key_event) = event {
140            if key_event.kind == KeyEventKind::Press {
141                if let KeyCode::Char('q') = key_event.code {
142                    break Ok(());
143                }
144            }
145        }
146    }
147}
Source

pub const fn size(&self) -> Rect

👎Deprecated: use .area() as it’s the more correct name

The area of the current frame

This is guaranteed not to change during rendering, so may be called multiple times.

If your app listens for a resize event from the backend, it should ignore the values from the event for any calculations that are used to render the current frame and use this value instead as this is the area of the buffer that is used to render the current frame.

Source

pub fn render_widget<W>(&mut self, widget: W, area: Rect)
where W: Widget,

Render a Widget to the current buffer using Widget::render.

Usually the area argument is the size of the current frame or a sub-area of the current frame (which can be obtained using Layout to split the total area).

§Example
use ratatui::{layout::Rect, widgets::Block};

let block = Block::new();
let area = Rect::new(0, 0, 5, 5);
frame.render_widget(block, area);
Examples found in repository?
examples/basic_gradient.rs (line 53)
24fn run(
25    terminal: &mut ratatui::DefaultTerminal,
26    set: SegmentSet,
27) -> io::Result<()> {
28    use tui_gradient_block::gradient_block::GradientBlock;
29    let block = GradientBlock::new()
30        .with_set(set)
31        .left_gradient(solid((48, 174, 209)))
32        .bottom_gradient(solid((48, 174, 209)))
33        .top_gradient(Box::new(
34            GradientBuilder::new()
35                .colors(&[
36                    Color::from_rgba8(48, 174, 209, 1),
37                    Color::from_rgba8(225, 22, 247, 1),
38                ])
39                .build::<colorgrad::LinearGradient>()
40                .unwrap(),
41        ))
42        .right_gradient(Box::new(
43            GradientBuilder::new()
44                .colors(&[
45                    Color::from_rgba8(225, 22, 247, 1),
46                    Color::from_rgba8(48, 174, 209, 1),
47                ])
48                .build::<colorgrad::LinearGradient>()
49                .unwrap(),
50        ));
51
52    loop {
53        terminal.draw(|f| f.render_widget(&block, f.area()))?;
54        let event = event::read()?;
55
56        if let Event::Key(key_event) = event {
57            if key_event.kind == KeyEventKind::Press {
58                if let KeyCode::Char('q') = key_event.code {
59                    break Ok(());
60                }
61            }
62        }
63    }
64}
More examples
Hide additional examples
examples/themes/zombie_dreams.rs (line 52)
15fn run(
16    terminal: &mut ratatui::DefaultTerminal,
17    set: SegmentSet,
18) -> io::Result<()> {
19    use ratatui::{text::Line, layout::{Constraint, Direction, Layout}};
20    use tui_gradient_block::{
21        gradient_block::GradientBlock,
22        theme_presets::cool::t_zombie_dreams,
23    };
24    let theme = t_zombie_dreams::full();
25    let blocks = vec![
26        GradientBlock::new()
27            .with_gradient(theme.double_corners_left)
28            .with_set(set.clone()),
29        GradientBlock::new().title_top(Line::from(tui_rule::generate_gradient_text!("Zombie Dreams", theme.right.top)).centered())
30            .with_gradient(theme.misc1)
31            .with_set(set.clone()),
32        GradientBlock::new()
33            .with_gradient(theme.double_corners_right)
34            .with_set(set.clone()),
35    ];
36
37    loop {
38        terminal.draw(|f| {
39            let base = Layout::new(
40                Direction::Horizontal,
41                [
42                    Constraint::Percentage(33),
43                    Constraint::Percentage(33),
44                    Constraint::Percentage(34),
45                ],
46            )
47            .vertical_margin(1)
48            .horizontal_margin(1)
49            .spacing(3)
50            .split(f.area());
51            for (block, area) in blocks.iter().zip(base.iter()) {
52                f.render_widget(block, *area);
53            }
54        })?;
55        let event = event::read()?;
56
57        if let Event::Key(key_event) = event {
58            if key_event.kind == KeyEventKind::Press {
59                if let KeyCode::Char('q') = key_event.code {
60                    break Ok(());
61                }
62            }
63        }
64    }
65}
examples/themes/misty_blue.rs (line 129)
14fn run(
15    terminal: &mut ratatui::DefaultTerminal,
16    set: SegmentSet,
17) -> io::Result<()> {
18    use ratatui::layout::{Constraint, Direction, Layout};
19    use tui_gradient_block::{
20        gradient_block::GradientBlock,
21        theme_presets::cool::t_misty_blue,
22    };
23    let titles = t_misty_blue::titles();
24    let theme = t_misty_blue::full();
25    let blocks_top = vec![
26        GradientBlock::new()
27            .title(titles.up.0, titles.up.1)
28            .with_gradient(theme.up)
29            .with_set(set.clone()),
30        GradientBlock::new()
31            .title(titles.down.0, titles.down.1)
32            .with_gradient(theme.down)
33            .with_set(set.clone()),
34        GradientBlock::new()
35            .title(titles.left.0, titles.left.1)
36            .with_gradient(theme.left)
37            .with_set(set.clone()),
38        GradientBlock::new()
39            .title(titles.right.0, titles.right.1)
40            .with_gradient(theme.right)
41            .with_set(set.clone()),
42        GradientBlock::new()
43            .title(titles.top_left.0, titles.top_left.1)
44            .with_gradient(theme.top_left)
45            .with_set(set.clone()),
46        GradientBlock::new()
47            .title(titles.top_right.0, titles.top_right.1)
48            .with_gradient(theme.top_right)
49            .with_set(set.clone()),
50        GradientBlock::new()
51            .title(titles.bottom_left.0, titles.bottom_left.1)
52            .with_gradient(theme.bottom_left)
53            .with_set(set.clone()),
54    ];
55    let blocks_bottom = vec![
56        GradientBlock::new()
57            .title(titles.bottom_right.0, titles.bottom_right.1)
58            .with_gradient(theme.bottom_right)
59            .with_set(set.clone()),
60        GradientBlock::new()
61            .title(
62                titles.double_corners_left.0,
63                titles.double_corners_left.1,
64            )
65            .with_gradient(theme.double_corners_left)
66            .with_set(set.clone()),
67        GradientBlock::new()
68            .title(
69                titles.double_corners_right.0,
70                titles.double_corners_right.1,
71            )
72            .with_gradient(theme.double_corners_right)
73            .with_set(set.clone()),
74        GradientBlock::new()
75            .title(titles.vertical.0, titles.vertical.1)
76            .with_gradient(theme.vertical)
77            .with_set(set.clone()),
78        GradientBlock::new()
79            .title(titles.horizontal.0, titles.horizontal.1)
80            .with_gradient(theme.horizontal)
81            .with_set(set.clone()),
82        GradientBlock::new()
83            .title(titles.misc1.0, titles.misc1.1)
84            .with_gradient(theme.misc1)
85            .with_set(set.clone()),
86        GradientBlock::new()
87            .title(titles.misc2.0, titles.misc2.1)
88            .with_gradient(theme.misc2)
89            .with_set(set.clone()),
90    ];
91
92    loop {
93        terminal.draw(|f| {
94            let base = Layout::new(
95                Direction::Vertical,
96                [
97                    Constraint::Percentage(50),
98                    Constraint::Percentage(50),
99                ],
100            )
101            .split(f.area());
102            let top = Layout::new(
103                Direction::Horizontal,
104                [
105                    Constraint::Percentage(14),
106                    Constraint::Percentage(14),
107                    Constraint::Percentage(14),
108                    Constraint::Percentage(14),
109                    Constraint::Percentage(14),
110                    Constraint::Percentage(15),
111                    Constraint::Percentage(15),
112                ],
113            )
114            .split(base[0]);
115            let bottom = Layout::new(
116                Direction::Horizontal,
117                [
118                    Constraint::Percentage(14),
119                    Constraint::Percentage(14),
120                    Constraint::Percentage(14),
121                    Constraint::Percentage(14),
122                    Constraint::Percentage(14),
123                    Constraint::Percentage(15),
124                    Constraint::Percentage(15),
125                ],
126            )
127            .split(base[1]);
128            for (block, area) in blocks_top.iter().zip(top.iter()) {
129                f.render_widget(block, *area);
130            }
131            for (block, area) in
132                blocks_bottom.iter().zip(bottom.iter())
133            {
134                f.render_widget(block, *area);
135            }
136        })?;
137        let event = event::read()?;
138
139        if let Event::Key(key_event) = event {
140            if key_event.kind == KeyEventKind::Press {
141                if let KeyCode::Char('q') = key_event.code {
142                    break Ok(());
143                }
144            }
145        }
146    }
147}
examples/themes/monochrome.rs (line 129)
14fn run(
15    terminal: &mut ratatui::DefaultTerminal,
16    set: SegmentSet,
17) -> io::Result<()> {
18    use ratatui::layout::{Constraint, Direction, Layout};
19    use tui_gradient_block::{
20        gradient_block::GradientBlock,
21        theme_presets::misc::t_monochrome,
22    };
23    let titles = t_monochrome::titles();
24    let theme = t_monochrome::full();
25    let blocks_top = vec![
26        GradientBlock::new()
27            .title(titles.up.0, titles.up.1)
28            .with_gradient(theme.up)
29            .with_set(set.clone()),
30        GradientBlock::new()
31            .title(titles.down.0, titles.down.1)
32            .with_gradient(theme.down)
33            .with_set(set.clone()),
34        GradientBlock::new()
35            .title(titles.left.0, titles.left.1)
36            .with_gradient(theme.left)
37            .with_set(set.clone()),
38        GradientBlock::new()
39            .title(titles.right.0, titles.right.1)
40            .with_gradient(theme.right)
41            .with_set(set.clone()),
42        GradientBlock::new()
43            .title(titles.top_left.0, titles.top_left.1)
44            .with_gradient(theme.top_left)
45            .with_set(set.clone()),
46        GradientBlock::new()
47            .title(titles.top_right.0, titles.top_right.1)
48            .with_gradient(theme.top_right)
49            .with_set(set.clone()),
50        GradientBlock::new()
51            .title(titles.bottom_left.0, titles.bottom_left.1)
52            .with_gradient(theme.bottom_left)
53            .with_set(set.clone()),
54    ];
55    let blocks_bottom = vec![
56        GradientBlock::new()
57            .title(titles.bottom_right.0, titles.bottom_right.1)
58            .with_gradient(theme.bottom_right)
59            .with_set(set.clone()),
60        GradientBlock::new()
61            .title(
62                titles.double_corners_left.0,
63                titles.double_corners_left.1,
64            )
65            .with_gradient(theme.double_corners_left)
66            .with_set(set.clone()),
67        GradientBlock::new()
68            .title(
69                titles.double_corners_right.0,
70                titles.double_corners_right.1,
71            )
72            .with_gradient(theme.double_corners_right)
73            .with_set(set.clone()),
74        GradientBlock::new()
75            .title(titles.vertical.0, titles.vertical.1)
76            .with_gradient(theme.vertical)
77            .with_set(set.clone()),
78        GradientBlock::new()
79            .title(titles.horizontal.0, titles.horizontal.1)
80            .with_gradient(theme.horizontal)
81            .with_set(set.clone()),
82        GradientBlock::new()
83            .title(titles.misc1.0, titles.misc1.1)
84            .with_gradient(theme.misc1)
85            .with_set(set.clone()),
86        GradientBlock::new()
87            .title(titles.misc2.0, titles.misc2.1)
88            .with_gradient(theme.misc2)
89            .with_set(set.clone()),
90    ];
91
92    loop {
93        terminal.draw(|f| {
94            let base = Layout::new(
95                Direction::Vertical,
96                [
97                    Constraint::Percentage(50),
98                    Constraint::Percentage(50),
99                ],
100            )
101            .split(f.area());
102            let top = Layout::new(
103                Direction::Horizontal,
104                [
105                    Constraint::Percentage(14),
106                    Constraint::Percentage(14),
107                    Constraint::Percentage(14),
108                    Constraint::Percentage(14),
109                    Constraint::Percentage(14),
110                    Constraint::Percentage(15),
111                    Constraint::Percentage(15),
112                ],
113            )
114            .split(base[0]);
115            let bottom = Layout::new(
116                Direction::Horizontal,
117                [
118                    Constraint::Percentage(14),
119                    Constraint::Percentage(14),
120                    Constraint::Percentage(14),
121                    Constraint::Percentage(14),
122                    Constraint::Percentage(14),
123                    Constraint::Percentage(15),
124                    Constraint::Percentage(15),
125                ],
126            )
127            .split(base[1]);
128            for (block, area) in blocks_top.iter().zip(top.iter()) {
129                f.render_widget(block, *area);
130            }
131            for (block, area) in
132                blocks_bottom.iter().zip(bottom.iter())
133            {
134                f.render_widget(block, *area);
135            }
136        })?;
137        let event = event::read()?;
138
139        if let Event::Key(key_event) = event {
140            if key_event.kind == KeyEventKind::Press {
141                if let KeyCode::Char('q') = key_event.code {
142                    break Ok(());
143                }
144            }
145        }
146    }
147}
examples/themes/minty_green.rs (line 129)
14fn run(
15    terminal: &mut ratatui::DefaultTerminal,
16    set: SegmentSet,
17) -> io::Result<()> {
18    use ratatui::layout::{Constraint, Direction, Layout};
19    use tui_gradient_block::{
20        gradient_block::GradientBlock,
21        theme_presets::cool::t_minty_green,
22    };
23    let titles = t_minty_green::titles();
24    let theme = t_minty_green::full();
25    let blocks_top = vec![
26        GradientBlock::new()
27            .title(titles.up.0, titles.up.1)
28            .with_gradient(theme.up)
29            .with_set(set.clone()),
30        GradientBlock::new()
31            .title(titles.down.0, titles.down.1)
32            .with_gradient(theme.down)
33            .with_set(set.clone()),
34        GradientBlock::new()
35            .title(titles.left.0, titles.left.1)
36            .with_gradient(theme.left)
37            .with_set(set.clone()),
38        GradientBlock::new()
39            .title(titles.right.0, titles.right.1)
40            .with_gradient(theme.right)
41            .with_set(set.clone()),
42        GradientBlock::new()
43            .title(titles.top_left.0, titles.top_left.1)
44            .with_gradient(theme.top_left)
45            .with_set(set.clone()),
46        GradientBlock::new()
47            .title(titles.top_right.0, titles.top_right.1)
48            .with_gradient(theme.top_right)
49            .with_set(set.clone()),
50        GradientBlock::new()
51            .title(titles.bottom_left.0, titles.bottom_left.1)
52            .with_gradient(theme.bottom_left)
53            .with_set(set.clone()),
54    ];
55    let blocks_bottom = vec![
56        GradientBlock::new()
57            .title(titles.bottom_right.0, titles.bottom_right.1)
58            .with_gradient(theme.bottom_right)
59            .with_set(set.clone()),
60        GradientBlock::new()
61            .title(
62                titles.double_corners_left.0,
63                titles.double_corners_left.1,
64            )
65            .with_gradient(theme.double_corners_left)
66            .with_set(set.clone()),
67        GradientBlock::new()
68            .title(
69                titles.double_corners_right.0,
70                titles.double_corners_right.1,
71            )
72            .with_gradient(theme.double_corners_right)
73            .with_set(set.clone()),
74        GradientBlock::new()
75            .title(titles.vertical.0, titles.vertical.1)
76            .with_gradient(theme.vertical)
77            .with_set(set.clone()),
78        GradientBlock::new()
79            .title(titles.horizontal.0, titles.horizontal.1)
80            .with_gradient(theme.horizontal)
81            .with_set(set.clone()),
82        GradientBlock::new()
83            .title(titles.misc1.0, titles.misc1.1)
84            .with_gradient(theme.misc1)
85            .with_set(set.clone()),
86        GradientBlock::new()
87            .title(titles.misc2.0, titles.misc2.1)
88            .with_gradient(theme.misc2)
89            .with_set(set.clone()),
90    ];
91
92    loop {
93        terminal.draw(|f| {
94            let base = Layout::new(
95                Direction::Vertical,
96                [
97                    Constraint::Percentage(50),
98                    Constraint::Percentage(50),
99                ],
100            )
101            .split(f.area());
102            let top = Layout::new(
103                Direction::Horizontal,
104                [
105                    Constraint::Percentage(14),
106                    Constraint::Percentage(14),
107                    Constraint::Percentage(14),
108                    Constraint::Percentage(14),
109                    Constraint::Percentage(14),
110                    Constraint::Percentage(15),
111                    Constraint::Percentage(15),
112                ],
113            )
114            .split(base[0]);
115            let bottom = Layout::new(
116                Direction::Horizontal,
117                [
118                    Constraint::Percentage(14),
119                    Constraint::Percentage(14),
120                    Constraint::Percentage(14),
121                    Constraint::Percentage(14),
122                    Constraint::Percentage(14),
123                    Constraint::Percentage(15),
124                    Constraint::Percentage(15),
125                ],
126            )
127            .split(base[1]);
128            for (block, area) in blocks_top.iter().zip(top.iter()) {
129                f.render_widget(block, *area);
130            }
131            for (block, area) in
132                blocks_bottom.iter().zip(bottom.iter())
133            {
134                f.render_widget(block, *area);
135            }
136        })?;
137        let event = event::read()?;
138
139        if let Event::Key(key_event) = event {
140            if key_event.kind == KeyEventKind::Press {
141                if let KeyCode::Char('q') = key_event.code {
142                    break Ok(());
143                }
144            }
145        }
146    }
147}
examples/themes/rusty_ruins.rs (line 129)
14fn run(
15    terminal: &mut ratatui::DefaultTerminal,
16    set: SegmentSet,
17) -> io::Result<()> {
18    use ratatui::layout::{Constraint, Direction, Layout};
19    use tui_gradient_block::{
20        gradient_block::GradientBlock,
21        theme_presets::warm::t_rusty_ruins,
22    };
23    let titles = t_rusty_ruins::titles();
24    let theme = t_rusty_ruins::full();
25    let blocks_top = vec![
26        GradientBlock::new()
27            .title(titles.up.0, titles.up.1)
28            .with_gradient(theme.up)
29            .with_set(set.clone()),
30        GradientBlock::new()
31            .title(titles.down.0, titles.down.1)
32            .with_gradient(theme.down)
33            .with_set(set.clone()),
34        GradientBlock::new()
35            .title(titles.left.0, titles.left.1)
36            .with_gradient(theme.left)
37            .with_set(set.clone()),
38        GradientBlock::new()
39            .title(titles.right.0, titles.right.1)
40            .with_gradient(theme.right)
41            .with_set(set.clone()),
42        GradientBlock::new()
43            .title(titles.top_left.0, titles.top_left.1)
44            .with_gradient(theme.top_left)
45            .with_set(set.clone()),
46        GradientBlock::new()
47            .title(titles.top_right.0, titles.top_right.1)
48            .with_gradient(theme.top_right)
49            .with_set(set.clone()),
50        GradientBlock::new()
51            .title(titles.bottom_left.0, titles.bottom_left.1)
52            .with_gradient(theme.bottom_left)
53            .with_set(set.clone()),
54    ];
55    let blocks_bottom = vec![
56        GradientBlock::new()
57            .title(titles.bottom_right.0, titles.bottom_right.1)
58            .with_gradient(theme.bottom_right)
59            .with_set(set.clone()),
60        GradientBlock::new()
61            .title(
62                titles.double_corners_left.0,
63                titles.double_corners_left.1,
64            )
65            .with_gradient(theme.double_corners_left)
66            .with_set(set.clone()),
67        GradientBlock::new()
68            .title(
69                titles.double_corners_right.0,
70                titles.double_corners_right.1,
71            )
72            .with_gradient(theme.double_corners_right)
73            .with_set(set.clone()),
74        GradientBlock::new()
75            .title(titles.vertical.0, titles.vertical.1)
76            .with_gradient(theme.vertical)
77            .with_set(set.clone()),
78        GradientBlock::new()
79            .title(titles.horizontal.0, titles.horizontal.1)
80            .with_gradient(theme.horizontal)
81            .with_set(set.clone()),
82        GradientBlock::new()
83            .title(titles.misc1.0, titles.misc1.1)
84            .with_gradient(theme.misc1)
85            .with_set(set.clone()),
86        GradientBlock::new()
87            .title(titles.misc2.0, titles.misc2.1)
88            .with_gradient(theme.misc2)
89            .with_set(set.clone()),
90    ];
91
92    loop {
93        terminal.draw(|f| {
94            let base = Layout::new(
95                Direction::Vertical,
96                [
97                    Constraint::Percentage(50),
98                    Constraint::Percentage(50),
99                ],
100            )
101            .split(f.area());
102            let top = Layout::new(
103                Direction::Horizontal,
104                [
105                    Constraint::Percentage(14),
106                    Constraint::Percentage(14),
107                    Constraint::Percentage(14),
108                    Constraint::Percentage(14),
109                    Constraint::Percentage(14),
110                    Constraint::Percentage(15),
111                    Constraint::Percentage(15),
112                ],
113            )
114            .split(base[0]);
115            let bottom = Layout::new(
116                Direction::Horizontal,
117                [
118                    Constraint::Percentage(14),
119                    Constraint::Percentage(14),
120                    Constraint::Percentage(14),
121                    Constraint::Percentage(14),
122                    Constraint::Percentage(14),
123                    Constraint::Percentage(15),
124                    Constraint::Percentage(15),
125                ],
126            )
127            .split(base[1]);
128            for (block, area) in blocks_top.iter().zip(top.iter()) {
129                f.render_widget(block, *area);
130            }
131            for (block, area) in
132                blocks_bottom.iter().zip(bottom.iter())
133            {
134                f.render_widget(block, *area);
135            }
136        })?;
137        let event = event::read()?;
138
139        if let Event::Key(key_event) = event {
140            if key_event.kind == KeyEventKind::Press {
141                if let KeyCode::Char('q') = key_event.code {
142                    break Ok(());
143                }
144            }
145        }
146    }
147}
Source

pub fn render_widget_ref<W>(&mut self, widget: W, area: Rect)
where W: WidgetRef,

Render a WidgetRef to the current buffer using WidgetRef::render_ref.

Usually the area argument is the size of the current frame or a sub-area of the current frame (which can be obtained using [Layout] to split the total area).

§Example
use ratatui::{layout::Rect, widgets::Block};

let block = Block::new();
let area = Rect::new(0, 0, 5, 5);
frame.render_widget_ref(block, area);
§Stability

This API is marked as unstable and is only available when the unstable-widget-ref crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source

pub fn render_stateful_widget<W>( &mut self, widget: W, area: Rect, state: &mut <W as StatefulWidget>::State, )
where W: StatefulWidget,

Render a StatefulWidget to the current buffer using StatefulWidget::render.

Usually the area argument is the size of the current frame or a sub-area of the current frame (which can be obtained using Layout to split the total area).

The last argument should be an instance of the StatefulWidget::State associated to the given StatefulWidget.

§Example
use ratatui::{
    layout::Rect,
    widgets::{List, ListItem, ListState},
};

let mut state = ListState::default().with_selected(Some(1));
let list = List::new(vec![ListItem::new("Item 1"), ListItem::new("Item 2")]);
let area = Rect::new(0, 0, 5, 5);
frame.render_stateful_widget(list, area, &mut state);
Source

pub fn render_stateful_widget_ref<W>( &mut self, widget: W, area: Rect, state: &mut <W as StatefulWidgetRef>::State, )

Render a StatefulWidgetRef to the current buffer using StatefulWidgetRef::render_ref.

Usually the area argument is the size of the current frame or a sub-area of the current frame (which can be obtained using [Layout] to split the total area).

The last argument should be an instance of the StatefulWidgetRef::State associated to the given StatefulWidgetRef.

§Example
use ratatui::{
    layout::Rect,
    widgets::{List, ListItem, ListState},
};

let mut state = ListState::default().with_selected(Some(1));
let list = List::new(vec![ListItem::new("Item 1"), ListItem::new("Item 2")]);
let area = Rect::new(0, 0, 5, 5);
frame.render_stateful_widget_ref(list, area, &mut state);
§Stability

This API is marked as unstable and is only available when the unstable-widget-ref crate feature is enabled. This comes with no stability guarantees, and could be changed or removed at any time.

Source

pub fn set_cursor_position<P>(&mut self, position: P)
where P: Into<Position>,

After drawing this frame, make the cursor visible and put it at the specified (x, y) coordinates. If this method is not called, the cursor will be hidden.

Note that this will interfere with calls to Terminal::hide_cursor, Terminal::show_cursor, and Terminal::set_cursor_position. Pick one of the APIs and stick with it.

Source

pub fn set_cursor(&mut self, x: u16, y: u16)

👎Deprecated: the method set_cursor_position indicates more clearly what about the cursor to set

After drawing this frame, make the cursor visible and put it at the specified (x, y) coordinates. If this method is not called, the cursor will be hidden.

Note that this will interfere with calls to Terminal::hide_cursor, Terminal::show_cursor, and Terminal::set_cursor_position. Pick one of the APIs and stick with it.

Source

pub fn buffer_mut(&mut self) -> &mut Buffer

Gets the buffer that this Frame draws into as a mutable reference.

Source

pub const fn count(&self) -> usize

Returns the current frame count.

This method provides access to the frame count, which is a sequence number indicating how many frames have been rendered up to (but not including) this one. It can be used for purposes such as animation, performance tracking, or debugging.

Each time a frame has been rendered, this count is incremented, providing a consistent way to reference the order and number of frames processed by the terminal. When count reaches its maximum value (usize::MAX), it wraps around to zero.

This count is particularly useful when dealing with dynamic content or animations where the state of the display changes over time. By tracking the frame count, developers can synchronize updates or changes to the content with the rendering process.

§Examples
let current_count = frame.count();
println!("Current frame count: {}", current_count);

Trait Implementations§

Source§

impl<'a> Debug for Frame<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'a> Hash for Frame<'a>

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Frame<'a>

§

impl<'a> RefUnwindSafe for Frame<'a>

§

impl<'a> Send for Frame<'a>

§

impl<'a> Sync for Frame<'a>

§

impl<'a> Unpin for Frame<'a>

§

impl<'a> !UnwindSafe for Frame<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.