Skip to content

Commit

Permalink
Remove tokio support (#109)
Browse files Browse the repository at this point in the history
* feat: Remove tokio support

* remove tokio fully

---------

Co-authored-by: Ivan Krivosheev <py.krivosheev@gmail.com>
  • Loading branch information
folkertdev and ikrivosheev authored Dec 3, 2024
1 parent 9d4ad68 commit 84d7188
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 274 deletions.
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,16 +19,12 @@ 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.5.4", features = ["quickcheck1"] }
quickcheck = "1.0"
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"]
35 changes: 0 additions & 35 deletions src/bufread.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 bz2 encoder, or compressor.
Expand Down Expand Up @@ -119,9 +114,6 @@ impl<R: BufRead> Read for BzEncoder<R> {
}
}

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

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

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

impl<R: BufRead> BzDecoder<R> {
/// Creates a new decoder which will decompress data read from the given
/// stream.
Expand Down Expand Up @@ -236,9 +221,6 @@ impl<R: BufRead> Read for BzDecoder<R> {
}
}

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

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

#[cfg(feature = "tokio")]
impl<R: AsyncWrite> 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, and the
Expand Down Expand Up @@ -296,9 +271,6 @@ impl<R: BufRead> Read for MultiBzDecoder<R> {
}
}

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

impl<R: BufRead + Write> Write for MultiBzDecoder<R> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.get_mut().write(buf)
Expand All @@ -309,13 +281,6 @@ impl<R: BufRead + Write> Write for MultiBzDecoder<R> {
}
}

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

#[cfg(test)]
mod tests {
use super::MultiBzDecoder;
Expand Down
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::quickcheck_types::{GenInterrupted, 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
Loading

0 comments on commit 84d7188

Please sign in to comment.