Skip to content

Commit

Permalink
Implement fmt::Display for ChurnRate and ObjectTotals
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelklishin committed Nov 25, 2024
1 parent d6b7ef7 commit ef55a27
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
//! This library is double licensed under the Apache 2.0 and MIT licenses.
//! This means that the user can choose either of the licenses.
extern crate alloc;

/// The primary API: a async HTTP API client
#[cfg(feature = "async")]
pub mod api;
Expand Down
23 changes: 23 additions & 0 deletions src/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,19 @@ pub struct ChurnRates {
channel_created: u32,
channel_closed: u32,
}
impl fmt::Display for ChurnRates {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "connection_created: {}", self.connection_created)?;
writeln!(f, "connection_closed: {}", self.connection_closed)?;
writeln!(f, "queue_declared: {}", self.queue_declared)?;
writeln!(f, "queue_created: {}", self.queue_created)?;
writeln!(f, "queue_deleted: {}", self.queue_deleted)?;
writeln!(f, "channel_created: {}", self.channel_created)?;
writeln!(f, "channel_closed: {}", self.channel_closed)?;

Ok(())
}
}

#[derive(Debug, Deserialize, Clone, Eq, PartialEq)]
#[cfg_attr(feature = "tabled", derive(Tabled))]
Expand All @@ -674,6 +687,16 @@ pub struct ObjectTotals {
queues: u64,
exchanges: u64,
}
impl fmt::Display for ObjectTotals {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "connections: {}", self.connections)?;
writeln!(f, "channels: {}", self.channels)?;
writeln!(f, "queues: {}", self.queues)?;
writeln!(f, "exchanges: {}", self.exchanges)?;

Ok(())
}
}

#[derive(Debug, Deserialize, Clone, Eq, PartialEq)]
#[cfg_attr(feature = "tabled", derive(Tabled))]
Expand Down

0 comments on commit ef55a27

Please sign in to comment.