From 3d8419571487027ed806fefa282fc1599cf76c1e Mon Sep 17 00:00:00 2001 From: yggverse Date: Sun, 19 Jan 2025 11:02:03 +0200 Subject: [PATCH] implement display trait --- .../browser/window/tab/item/page/status.rs | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/app/browser/window/tab/item/page/status.rs b/src/app/browser/window/tab/item/page/status.rs index d0212a62..bef4d7b7 100644 --- a/src/app/browser/window/tab/item/page/status.rs +++ b/src/app/browser/window/tab/item/page/status.rs @@ -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)) + } + } + } +}