@@ -88,7 +88,9 @@ impl StructuredSerializer<MessageRecord> for MessageRecord {
8888}
8989
9090/// Extension Trait for [`BaseRecord`] that fills the record with a [`MessageRecord`].
91- pub trait BaseRecordExt < ' a , K : ToBytes + ?Sized > {
91+ ///
92+ /// This trait is sealed and cannot be implemented for types outside of this crate.
93+ pub trait BaseRecordExt < ' a , K : ToBytes + ?Sized > : private:: Sealed {
9294 /// Fill this [`BaseRecord`] with a [`MessageRecord`].
9395 fn message_record (
9496 self ,
@@ -112,7 +114,9 @@ impl<'a, K: ToBytes + ?Sized> BaseRecordExt<'a, K> for BaseRecord<'a, K, Vec<u8>
112114}
113115
114116/// Extension Trait for [`FutureRecord`] that fills the record with a [`MessageRecord`].
115- pub trait FutureRecordExt < ' a , K : ToBytes + ?Sized > {
117+ ///
118+ /// This trait is sealed and cannot be implemented for types outside of this crate.
119+ pub trait FutureRecordExt < ' a , K : ToBytes + ?Sized > : private:: Sealed {
116120 /// Fill this [`FutureRecord`] with a [`MessageRecord`].
117121 fn message_record ( self , message_record : & ' a MessageRecord ) -> FutureRecord < ' a , K , Vec < u8 > > ;
118122}
@@ -128,3 +132,16 @@ impl<'a, K: ToBytes + ?Sized> FutureRecordExt<'a, K> for FutureRecord<'a, K, Vec
128132 self
129133 }
130134}
135+
136+ mod private {
137+ // Sealing the FutureRecordExt and BaseRecordExt
138+ pub trait Sealed { }
139+ impl < K : rdkafka:: message:: ToBytes + ?Sized , V : rdkafka:: message:: ToBytes > Sealed
140+ for rdkafka:: producer:: FutureRecord < ' _ , K , V >
141+ {
142+ }
143+ impl < K : rdkafka:: message:: ToBytes + ?Sized , V : rdkafka:: message:: ToBytes > Sealed
144+ for rdkafka:: producer:: BaseRecord < ' _ , K , V >
145+ {
146+ }
147+ }
0 commit comments