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

feat: Remove tokio support #89

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:
run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }}
shell: bash
- run: cargo test
- run: cargo test --features tokio

rustfmt:
name: Rustfmt
Expand Down
4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,13 @@ categories = ["compression", "api-bindings"]
[dependencies]
libc = "0.2"
bzip2-sys = { version = "0.1.11", path = "bzip2-sys" }
tokio-io = { version = "0.1", optional = true }
futures = { version = "0.1", optional = true }

[dev-dependencies]
rand = "0.8"
partial-io = { version = "0.3", features = ["quickcheck"] }
quickcheck = "1.0"
quickcheck6 = { version = "0.6", package = "quickcheck" }
tokio-core = "0.1"

[features]
tokio = ["tokio-io", "futures"]
# Enable this feature if you want to have a statically linked bzip2
static = ["bzip2-sys/static"]
14 changes: 0 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,6 @@
//! incomplete and exactly 900K bytes, you probably need a
//! `MultiBzDecoder`.
//!
//! # Async I/O
//!
//! This crate optionally can support async I/O streams with the Tokio stack via
//! the `tokio` feature of this crate:
//!
//! ```toml
//! bzip2 = { version = "0.4", features = ["tokio"] }
//! ```
//!
//! All methods are internally capable of working with streams that may return
//! `ErrorKind::WouldBlock` when they're not ready to perform the particular
//! operation.
Expand All @@ -71,11 +62,6 @@ extern crate partial_io;
extern crate quickcheck;
#[cfg(test)]
extern crate rand;
#[cfg(feature = "tokio")]
#[macro_use]
extern crate tokio_io;
#[cfg(feature = "tokio")]
extern crate futures;

pub use mem::{Action, Compress, Decompress, Error, Status};

Expand Down
45 changes: 0 additions & 45 deletions src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
use std::io::prelude::*;
use std::io::{self, BufReader};

#[cfg(feature = "tokio")]
use futures::Poll;
#[cfg(feature = "tokio")]
use tokio_io::{AsyncRead, AsyncWrite};

use bufread;
use Compression;

Expand Down Expand Up @@ -76,9 +71,6 @@ impl<R: Read> Read for BzEncoder<R> {
}
}

#[cfg(feature = "tokio")]
impl<R: AsyncRead> AsyncRead for BzEncoder<R> {}

impl<W: Write + Read> Write for BzEncoder<W> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.get_mut().write(buf)
Expand All @@ -89,13 +81,6 @@ impl<W: Write + Read> Write for BzEncoder<W> {
}
}

#[cfg(feature = "tokio")]
impl<R: AsyncWrite + Read> AsyncWrite for BzEncoder<R> {
fn shutdown(&mut self) -> Poll<(), io::Error> {
self.get_mut().shutdown()
}
}

impl<R: Read> BzDecoder<R> {
/// Create a new decompression stream, which will read compressed
/// data from the given input stream and decompress it.
Expand Down Expand Up @@ -147,9 +132,6 @@ impl<R: Read> Read for BzDecoder<R> {
}
}

#[cfg(feature = "tokio")]
impl<R: AsyncRead + Read> AsyncRead for BzDecoder<R> {}

impl<W: Write + Read> Write for BzDecoder<W> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.get_mut().write(buf)
Expand All @@ -160,13 +142,6 @@ impl<W: Write + Read> Write for BzDecoder<W> {
}
}

#[cfg(feature = "tokio")]
impl<R: AsyncWrite + Read> AsyncWrite for BzDecoder<R> {
fn shutdown(&mut self) -> Poll<(), io::Error> {
self.get_mut().shutdown()
}
}

/// A bzip2 streaming decoder that decodes all members of a multistream
///
/// Wikipedia, particularly, uses bzip2 multistream for their dumps.
Expand Down Expand Up @@ -211,26 +186,6 @@ impl<R: Read> Read for MultiBzDecoder<R> {
}
}

#[cfg(feature = "tokio")]
impl<R: AsyncRead> AsyncRead for MultiBzDecoder<R> {}

impl<R: Read + Write> Write for MultiBzDecoder<R> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.get_mut().write(buf)
}

fn flush(&mut self) -> io::Result<()> {
self.get_mut().flush()
}
}

#[cfg(feature = "tokio")]
impl<R: AsyncWrite + AsyncRead> AsyncWrite for MultiBzDecoder<R> {
fn shutdown(&mut self) -> Poll<(), io::Error> {
self.get_mut().shutdown()
}
}

#[cfg(test)]
mod tests {
use partial_io::{GenInterrupted, PartialRead, PartialWithErrors};
Expand Down
47 changes: 0 additions & 47 deletions src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
use std::io;
use std::io::prelude::*;

#[cfg(feature = "tokio")]
use futures::Poll;
#[cfg(feature = "tokio")]
use tokio_io::{AsyncRead, AsyncWrite};

use {Action, Compress, Compression, Decompress, Status};

/// A compression stream which will have uncompressed data written to it and
Expand Down Expand Up @@ -151,31 +146,6 @@ impl<W: Write> Write for BzEncoder<W> {
}
}

#[cfg(feature = "tokio")]
impl<W: AsyncWrite> AsyncWrite for BzEncoder<W> {
fn shutdown(&mut self) -> Poll<(), io::Error> {
try_nb!(self.try_finish());
self.get_mut().shutdown()
}
}

impl<W: Read + Write> Read for BzEncoder<W> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.get_mut().read(buf)
}
}

#[cfg(feature = "tokio")]
impl<W: AsyncRead + AsyncWrite> AsyncRead for BzEncoder<W> {}

impl<W: Write> Drop for BzEncoder<W> {
fn drop(&mut self) {
if self.obj.is_some() {
let _ = self.try_finish();
}
}
}

impl<W: Write> BzDecoder<W> {
/// Create a new decoding stream which will decompress all data written
/// to it into `obj`.
Expand Down Expand Up @@ -287,23 +257,6 @@ impl<W: Write> Write for BzDecoder<W> {
}
}

#[cfg(feature = "tokio")]
impl<W: AsyncWrite> AsyncWrite for BzDecoder<W> {
fn shutdown(&mut self) -> Poll<(), io::Error> {
try_nb!(self.try_finish());
self.get_mut().shutdown()
}
}

impl<W: Read + Write> Read for BzDecoder<W> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.get_mut().read(buf)
}
}

#[cfg(feature = "tokio")]
impl<W: AsyncRead + AsyncWrite> AsyncRead for BzDecoder<W> {}

impl<W: Write> Drop for BzDecoder<W> {
fn drop(&mut self) {
if self.obj.is_some() {
Expand Down