|
1 | 1 | //! Cluster metadata.
|
2 | 2 |
|
3 | 3 | use std::ffi::CStr;
|
| 4 | +use std::fmt; |
4 | 5 | use std::slice;
|
5 | 6 |
|
6 | 7 | use rdkafka_sys as rdsys;
|
@@ -33,6 +34,16 @@ impl MetadataBroker {
|
33 | 34 | }
|
34 | 35 | }
|
35 | 36 |
|
| 37 | +impl fmt::Debug for MetadataBroker { |
| 38 | + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 39 | + f.debug_struct("MetadataBroker") |
| 40 | + .field("id", &self.id()) |
| 41 | + .field("host", &self.host()) |
| 42 | + .field("port", &self.port()) |
| 43 | + .finish() |
| 44 | + } |
| 45 | +} |
| 46 | + |
36 | 47 | /// Partition metadata information.
|
37 | 48 | pub struct MetadataPartition(RDKafkaMetadataPartition);
|
38 | 49 |
|
@@ -69,6 +80,21 @@ impl MetadataPartition {
|
69 | 80 | }
|
70 | 81 | }
|
71 | 82 |
|
| 83 | +impl fmt::Debug for MetadataPartition { |
| 84 | + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 85 | + let mut debug_struct = f.debug_struct("MetadataPartition"); |
| 86 | + debug_struct.field("id", &self.id()); |
| 87 | + if let Some(err) = self.error() { |
| 88 | + debug_struct.field("error", &err); |
| 89 | + } |
| 90 | + debug_struct |
| 91 | + .field("leader", &self.leader()) |
| 92 | + .field("replicas", &self.replicas()) |
| 93 | + .field("isr", &self.isr()) // In-Sync Replicas |
| 94 | + .finish() |
| 95 | + } |
| 96 | +} |
| 97 | + |
72 | 98 | /// Topic metadata information.
|
73 | 99 | pub struct MetadataTopic(RDKafkaMetadataTopic);
|
74 | 100 |
|
@@ -103,6 +129,18 @@ impl MetadataTopic {
|
103 | 129 | }
|
104 | 130 | }
|
105 | 131 |
|
| 132 | +impl fmt::Debug for MetadataTopic { |
| 133 | + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 134 | + let mut debug_struct = f.debug_struct("MetadataTopic"); |
| 135 | + debug_struct.field("name", &self.name()); |
| 136 | + if let Some(err) = self.error() { |
| 137 | + debug_struct.field("error", &err); |
| 138 | + } |
| 139 | + debug_struct.field("partitions", &self.partitions()); |
| 140 | + debug_struct.finish() |
| 141 | + } |
| 142 | +} |
| 143 | + |
106 | 144 | /// Metadata container.
|
107 | 145 | ///
|
108 | 146 | /// This structure wraps the metadata pointer returned by rdkafka-sys, and
|
@@ -159,5 +197,16 @@ impl Metadata {
|
159 | 197 | }
|
160 | 198 | }
|
161 | 199 |
|
| 200 | +impl fmt::Debug for Metadata { |
| 201 | + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 202 | + f.debug_struct("Metadata") |
| 203 | + .field("orig_broker_name", &self.orig_broker_name()) |
| 204 | + .field("orig_broker_id", &self.orig_broker_id()) |
| 205 | + .field("brokers", &self.brokers()) |
| 206 | + .field("topics", &self.topics()) |
| 207 | + .finish() |
| 208 | + } |
| 209 | +} |
| 210 | + |
162 | 211 | unsafe impl Send for Metadata {}
|
163 | 212 | unsafe impl Sync for Metadata {}
|
0 commit comments