let mut reqs: Vec<OutstandingRequest>
= Vec::with_capacity(ic.max_requests_outstanding.sat());
- let mut rx_queue: Queue<Box<[u8]>> = default();
+ let mut rx_queue: FrameQueue = default();
// xxx check that ic settings are all honoured
Ok(())
}, |e| error!("{} #{}: rx discarding: {}", &ic, req_num, e));
- dbg!(&rx_queue);
}
}
}
queue: VecDeque<E>,
}
+#[derive(Default,Debug,Clone)]
+pub struct FrameQueue {
+ queue: Queue<Cervine<'static, Box<[u8]>, [u8]>>,
+}
+
impl<E> Debug for Queue<E> where E: AsRef<[u8]> {
#[throws(fmt::Error)]
fn fmt(&self, f: &mut fmt::Formatter) {
pub fn is_empty(&self) -> bool { self.content == 0 }
}
-impl<E> Extend<E> for Queue<E> where E: AsRef<[u8]> {
+impl FrameQueue {
+ pub fn push<B: Into<Box<[u8]>>>(&mut self, b: B) {
+ self.push_(b.into());
+ }
+ pub fn push_(&mut self, b: Box<[u8]>) {
+ self.queue.push_(Cervine::Owned(b));
+ self.queue.push_(Cervine::Borrowed(&SLIP_END_SLICE));
+ }
+ pub fn is_empty(&self) -> bool { self.queue.is_empty() }
+}
+
+impl<E> Extend<E> for FrameQueue where E: Into<Box<[u8]>> {
fn extend<I>(&mut self, it: I)
where I: IntoIterator<Item=E>
{
}
}
}
+
+impl hyper::body::Buf for FrameQueue {
+ fn remaining(&self) -> usize { self.queue.remaining() }
+ fn chunk(&self) -> &[u8] { self.queue.chunk() }
+ fn advance(&mut self, cnt: usize) { self.queue.advance(cnt) }
+}