implement display trait

This commit is contained in:
yggverse 2025-01-19 11:02:03 +02:00
parent 613b724c9e
commit 3d84195714

View File

@ -1,6 +1,8 @@
/// Global dependencies
// Global dependencies
use super::client::{status::Gemini, Status as Client};
use crate::tool::format_time;
use gtk::glib::DateTime;
use std::fmt::{Display, Formatter, Result};
/// `Page` status
pub enum Status {
@ -44,3 +46,34 @@ impl Status {
}
}
}
impl Display for Status {
fn fmt(&self, f: &mut Formatter) -> Result {
match self {
Self::Client(client) => {
write!(f, "{client}")
}
Self::Failure { time } => {
write!(f, "[{}] Failure", format_time(time))
}
Self::Input { time } => {
write!(f, "[{}] Input issue", format_time(time))
}
Self::Loading { time } => {
write!(f, "[{}] Loading...", format_time(time))
}
Self::New { time } => {
write!(f, "[{}] New page", format_time(time))
}
Self::SessionRestore { time } => {
write!(f, "[{}] Session restore...", format_time(time))
}
Self::SessionRestored { time } => {
write!(f, "[{}] Session restored", format_time(time))
}
Self::Success { time } => {
write!(f, "[{}] Success", format_time(time))
}
}
}
}