Removed unused sub-module

This commit is contained in:
Mathias Hall-Andersen
2019-08-27 11:36:33 +02:00
parent a80e64014c
commit 3eb7f5e423
2 changed files with 2 additions and 88 deletions

View File

@@ -1,84 +0,0 @@
/* Ring buffer implementing the WireGuard queuing semantics:
*
* 1. A fixed sized buffer
* 2. Inserting into the buffer always succeeds, but might overwrite the oldest item
*/
const BUFFER_SIZE: usize = 1024;
pub struct DiscardingRingBuffer<T> {
buf: [Option<T>; BUFFER_SIZE],
idx: usize,
next: usize,
}
impl<T> DiscardingRingBuffer<T>
where
T: Copy,
{
pub fn new() -> Self {
DiscardingRingBuffer {
buf: [None; BUFFER_SIZE],
idx: 0,
next: 0,
}
}
pub fn empty(&mut self) {
self.next = 0;
self.idx = 0;
for i in 1..BUFFER_SIZE {
self.buf[i] = None;
}
}
pub fn push(&mut self, val: T) {
// assign next slot (free / oldest)
self.buf[self.idx] = Some(val);
self.idx += 1;
self.idx %= BUFFER_SIZE;
// check for wrap-around
if self.idx == self.next {
self.next += 1;
self.next %= BUFFER_SIZE;
}
}
pub fn consume(&mut self) -> Option<T> {
match self.buf[self.next] {
None => None,
some => {
self.buf[self.next] = None;
self.next += 1;
self.next %= BUFFER_SIZE;
some
}
}
}
pub fn has_element(&self) -> bool {
match self.buf[self.next] {
None => true,
_ => false,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use proptest::prelude::*;
proptest! {
#[test]
fn test_order(elems: Vec<usize>) {
let mut buf = DiscardingRingBuffer::new();
for e in &elems {
buf.push(e);
}
}
}
}

View File

@@ -1,10 +1,8 @@
mod anti_replay;
mod buffer;
mod device;
mod types;
// mod inbound;
mod workers;
mod peer;
mod workers;
pub use peer::Peer;
pub use device::Device;
pub use device::Device;pub use peer::Peer;