use core::fmt;
use crate::layout::Rect;
#[derive(Debug, Default, Clone, Eq, PartialEq, Hash)]
pub enum Viewport {
#[default]
Fullscreen,
Inline(u16),
Fixed(Rect),
}
impl fmt::Display for Viewport {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Fullscreen => write!(f, "Fullscreen"),
Self::Inline(height) => write!(f, "Inline({height})"),
Self::Fixed(area) => write!(f, "Fixed({area})"),
}
}
}
#[cfg(test)]
mod tests {
use alloc::string::ToString;
use super::*;
#[test]
fn viewport_to_string() {
assert_eq!(Viewport::Fullscreen.to_string(), "Fullscreen");
assert_eq!(Viewport::Inline(5).to_string(), "Inline(5)");
assert_eq!(
Viewport::Fixed(Rect::new(0, 0, 5, 5)).to_string(),
"Fixed(5x5+0+0)"
);
}
}