#[derive(Debug)]
pub struct UiError(pub String);
impl std::fmt::Display for UiError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "UI error: {}", self.0)
}
}
impl std::error::Error for UiError {}
impl From<std::io::Error> for UiError {
fn from(e: std::io::Error) -> Self {
UiError(e.to_string())
}
}
pub trait Ui {
fn prompt(&self, label: &str) -> Result<String, UiError>;
fn show_preview(&self, content: &str);
fn confirm(&self, msg: &str) -> Result<bool, UiError>;
fn println(&self, msg: &str);
}