diff --git a/src/structs.rs b/src/structs.rs index a5ead09..f2e544e 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -1,7 +1,7 @@ use chrono::prelude::*; use helpers::*; use serde::Deserialize; -use std::time::Duration; +use std::{fmt, time::Duration}; /// All information about a track. This is returned by the `currentsong` or `queue` commands. #[derive(Deserialize, Clone, Debug, Default, PartialEq)] @@ -57,6 +57,15 @@ pub struct Position { pub total_items: Option, } +impl fmt::Display for Position { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self.total_items { + Some(n) => write!(f, "{}/{}", self.item_position, n), + None => write!(f, "{}", self.item_position), + } + } +} + /// Current status as returned by `status`. /// /// Regarding optional `volume`: