diff --git a/bbqueue/src/queue.rs b/bbqueue/src/queue.rs index 6f0eb14..95a055e 100644 --- a/bbqueue/src/queue.rs +++ b/bbqueue/src/queue.rs @@ -145,6 +145,52 @@ impl crate::queue::ArcBBQueue { } } + /// Create a new [`FramedProducer`] for this [`BBQueue`] with a custom + /// frame length header type. + /// + /// This can be used to support large frame sizes by selecting a larger + /// [`LenHeader`](crate::prod_cons::framed::LenHeader) type such as + /// `usize`. + /// + /// The `H` header type MUST match the `H` used to create the paired + /// [`FramedConsumer`] (typically via + /// [`framed_consumer_with_header`](Self::framed_consumer_with_header)). + /// Header width is not stored in the queue itself, so a mismatch will + /// silently corrupt framing rather than producing a compile-time or + /// runtime error. Mixing framed with stream producers/consumers will not + /// result in UB either, but will also not work correctly. + pub fn framed_producer_with_header( + &self, + ) -> FramedProducer>, H> { + FramedProducer { + bbq: self.0.bbq_ref(), + pd: PhantomData, + } + } + + /// Create a new [`FramedConsumer`] for this [`BBQueue`] with a custom + /// frame length header type. + /// + /// This can be used to support large frame sizes by selecting a larger + /// [`LenHeader`](crate::prod_cons::framed::LenHeader) type such as + /// `usize`. + /// + /// The `H` header type MUST match the `H` used to create the paired + /// [`FramedProducer`] (typically via + /// [`framed_producer_with_header`](Self::framed_producer_with_header)). + /// Header width is not stored in the queue itself, so a mismatch will + /// silently corrupt framing rather than producing a compile-time or + /// runtime error. Mixing framed with stream producers/consumers will not + /// result in UB either, but will also not work correctly. + pub fn framed_consumer_with_header( + &self, + ) -> FramedConsumer>, H> { + FramedConsumer { + bbq: self.0.bbq_ref(), + pd: PhantomData, + } + } + /// Create a new [`StreamProducer`] for this [`BBQueue`] /// /// Although mixing stream and framed consumer/producers will not result in UB,