Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: switch from slice-deque to its fork slice-ring-buffer #4

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ edition = "2021"
memchr = "2.0"

# `slice_deque` is only supported on platforms with virtual memory
[target.'cfg(any(unix, windows))'.dependencies.slice-deque]
[target.'cfg(any(unix, windows))'.dependencies.slice-ring-buffer]
version = "0.3"
optional = true

[features]
default = ["slice-deque"]
slice-deque = ["dep:slice-ring-buffer"]
11 changes: 6 additions & 5 deletions src/buffer/slice_deque_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
//! namely Windows, OS X and Linux.
//!
//! [`slice-deque`]: https://crates.io/crates/slice-deque
extern crate slice_deque;
use self::slice_deque::SliceDeque;
extern crate slice_ring_buffer;
use self::slice_ring_buffer::SliceRingBuffer;

use std::cmp;
use std::mem::MaybeUninit;

pub struct SliceDequeBuf {
deque: SliceDeque<u8>,
deque: SliceRingBuffer<u8>,
}

/// Move-free buffer utilizing the [`slice-deque`] crate.
Expand All @@ -22,7 +23,7 @@ pub struct SliceDequeBuf {
impl SliceDequeBuf {
pub fn with_capacity(cap: usize) -> Self {
SliceDequeBuf {
deque: SliceDeque::with_capacity(cap),
deque: SliceRingBuffer::with_capacity(cap),
}
}

Expand Down Expand Up @@ -55,7 +56,7 @@ impl SliceDequeBuf {
&mut self.deque
}

pub unsafe fn write_buf(&mut self) -> &mut [u8] {
pub unsafe fn write_buf(&mut self) -> &mut [MaybeUninit<u8>] {
self.deque.tail_head_slice()
}

Expand Down
Loading