confluent_kafka/admin/
topic_listing.rs1use crate::common::Uuid;
18
19#[derive(Clone, Debug)]
21#[doc(alias = "org.apache.kafka.clients.admin.TopicListing")]
22pub struct TopicListing {
23 name: String,
24 topic_id: Uuid,
25 internal: bool,
26}
27
28impl TopicListing {
29 #[doc(alias = "org.apache.kafka.clients.admin.TopicListing#TopicListing")]
37 pub fn new(name: impl Into<String>, topic_id: Uuid, internal: bool) -> Self {
38 Self { name: name.into(), topic_id, internal }
39 }
40
41 #[doc(alias = "org.apache.kafka.clients.admin.TopicListing#topicId")]
43 pub fn topic_id(&self) -> Uuid {
44 self.topic_id
45 }
46
47 #[doc(alias = "org.apache.kafka.clients.admin.TopicListing#name")]
49 pub fn name(&self) -> &str {
50 &self.name
51 }
52
53 #[doc(alias = "org.apache.kafka.clients.admin.TopicListing#isInternal")]
56 pub fn is_internal(&self) -> bool {
57 self.internal
58 }
59}
60
61impl std::fmt::Display for TopicListing {
62 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
63 write!(f, "(name={}, topicId={}, internal={})", self.name, self.topic_id, self.internal)
64 }
65}
66
67#[cfg(test)]
68mod tests {
69 use super::*;
70
71 #[test]
72 fn accessors() {
73 let id = Uuid::new(1, 2);
74 let listing = TopicListing::new("t", id, true);
75 assert_eq!(listing.name(), "t");
76 assert_eq!(listing.topic_id(), id);
77 assert!(listing.is_internal());
78 }
79}