use async_trait::async_trait; use crate::{AsyncWidget, Frame, Size, Widget, WidthDb}; #[derive(Debug, Default, Clone, Copy)] pub struct Empty { pub size: Size, } impl Empty { pub fn new() -> Self { Self { size: Size::ZERO } } pub fn with_width(mut self, width: u16) -> Self { self.size.width = width; self } pub fn with_height(mut self, height: u16) -> Self { self.size.height = height; self } pub fn with_size(mut self, size: Size) -> Self { self.size = size; self } } impl Widget for Empty { fn size( &self, _widthdb: &mut WidthDb, _max_width: Option, _max_height: Option, ) -> Result { Ok(self.size) } fn draw(self, _frame: &mut Frame) -> Result<(), E> { Ok(()) } } #[async_trait] impl AsyncWidget for Empty { async fn size( &self, _widthdb: &mut WidthDb, _max_width: Option, _max_height: Option, ) -> Result { Ok(self.size) } async fn draw(self, _frame: &mut Frame) -> Result<(), E> { Ok(()) } }