From 62583d36f2f8e0ed2009fb81baa379160813ebd6 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 13 Dec 2022 19:23:32 +0000 Subject: [PATCH] QueuedBuf: Introduce QueuedBytes type aliases This is perhaps clearer and will make it easier to change this, which we are about to do. Signed-off-by: Ian Jackson --- src/queue.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/queue.rs b/src/queue.rs index c78413c..44b2c85 100644 --- a/src/queue.rs +++ b/src/queue.rs @@ -41,9 +41,13 @@ pub struct QueueBuf { #[derive(Default,Debug,Clone)] pub struct FrameQueueBuf { - queue: QueueBuf, [u8]>>, + queue: QueueBuf, } +pub type QueuedBytes = Cervine<'static, Box<[u8]>, [u8]>; +use Cervine::Owned as QueuedBytesOwned; +use Cervine::Borrowed as QueuedBytesBorrowed; + impl Debug for QueueBuf where E: AsRef<[u8]> { #[throws(fmt::Error)] fn fmt(&self, f: &mut fmt::Formatter) { @@ -72,15 +76,15 @@ impl FrameQueueBuf { self.push_esc_(b.into()); } fn push_esc_(&mut self, b: Box<[u8]>) { - self.queue.push_(Cervine::Owned(b)); - self.queue.push_(Cervine::Borrowed(&SLIP_END_SLICE)); + self.queue.push_( QueuedBytesOwned(b)); + self.queue.push_(QueuedBytesBorrowed(&SLIP_END_SLICE)); } pub fn esc_push(&mut self, b: Box<[u8]>) { - self.queue.push_(Cervine::Borrowed(&SLIP_END_SLICE)); - self.queue.push_(Cervine::Owned(b)); + self.queue.push_(QueuedBytesBorrowed(&SLIP_END_SLICE)); + self.queue.push_(QueuedBytesOwned(b)); } pub fn push_raw(&mut self, b: Box<[u8]>) { - self.queue.push_(Cervine::Owned(b)); + self.queue.push_(QueuedBytesOwned(b)); } pub fn is_empty(&self) -> bool { self.queue.is_empty() } pub fn len(&self) -> usize { self.queue.len() } -- 2.30.2