Skip to content

Commit

Permalink
Implement fmt::Display for Stream
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-rembridge committed May 8, 2024
1 parent 572882d commit 18fa07a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions server/src/streaming/streams/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::streaming::topics::topic::Topic;
use iggy::utils::byte_size::IggyByteSize;
use iggy::utils::timestamp::IggyTimestamp;
use std::collections::HashMap;
use std::fmt;
use std::sync::atomic::{AtomicU32, AtomicU64, Ordering};
use std::sync::Arc;

Expand All @@ -24,6 +25,15 @@ pub struct Stream {
pub(crate) storage: Arc<SystemStorage>,
}

impl fmt::Display for Stream {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "ID: {}, ", self.stream_id)?;
write!(f, "name: {}, ", self.name)?;
write!(f, "size bytes: {:?}, ", self.size_bytes)?;
write!(f, "messages count: {:?}", self.messages_count)
}
}

impl Stream {
pub fn empty(id: u32, config: Arc<SystemConfig>, storage: Arc<SystemStorage>) -> Self {
Stream::create(id, "", config, storage)
Expand Down Expand Up @@ -81,5 +91,6 @@ mod tests {
assert_eq!(stream.path, path);
assert_eq!(stream.topics_path, topics_path);
assert!(stream.topics.is_empty());
assert_eq!("ID: 1, name: test, size bytes: 0, messages count: 0", format!("{}", stream));
}
}

0 comments on commit 18fa07a

Please sign in to comment.