use std::sync::Arc;
use bbq2::{
queue::BBQueue,
traits::{coordination::cas::AtomicCoord, notifier::maitake::MaiNotSpsc, storage::BoxedSlice},
};
#[derive(Debug, PartialEq)]
pub enum ReceiverError {
SocketClosed,
}
pub type StdQueue = Arc<BBQueue<BoxedSlice, AtomicCoord, MaiNotSpsc>>;
pub fn new_std_queue(buffer: usize) -> StdQueue {
Arc::new(BBQueue::new_with_storage(BoxedSlice::new(buffer)))
}
pub(crate) mod acc {
pub use cobs_acc::FeedResult;
pub struct CobsAccumulator {
inner: cobs_acc::CobsAccumulator<Box<[u8]>>,
}
impl CobsAccumulator {
#[inline]
pub fn new(size: usize) -> Self {
Self {
inner: cobs_acc::CobsAccumulator::new_boxslice(size),
}
}
#[inline(always)]
pub fn feed_raw<'me, 'input>(
&'me mut self,
input: &'input mut [u8],
) -> FeedResult<'input, 'me> {
self.inner.feed_raw(input)
}
}
}