Skip to content
Merged
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
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ adler32 = { version = "1", default-features = false }
crc32fast = { version = "1.1.1", default-features = false }
dary_heap = "0.3.5"
libflate_lz77 = { path = "libflate_lz77", version = "2.2.0", default-features = false }
core2 = { version = "0.4", default-features = false, features = ["alloc"] }
no_std_io2 = { version = "0.9", default-features = false, features = ["alloc"] }

[features]
default = ["std"]
std = ["libflate_lz77/std", "core2/std"]
std = ["libflate_lz77/std", "no_std_io2/std"]

[dev-dependencies]
clap = { version = "4", features = ["derive"] }
Expand Down
4 changes: 2 additions & 2 deletions libflate_lz77/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ license = "MIT"

[dependencies]
rle-decode-fast = "1.0.0"
core2 = { version = "0.4", default-features = false, features = ["alloc"] }
no_std_io2 = { version = "0.9", default-features = false, features = ["alloc"] }
hashbrown = { version = "0.16" }

[dev-dependencies]
libflate = { path = "../", version = "2.0", default-features = false }

[features]
default = ["std"]
std = ["core2/std", "libflate/std"]
std = ["no_std_io2/std", "libflate/std"]
4 changes: 2 additions & 2 deletions libflate_lz77/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern crate alloc;
pub use self::default::{DefaultLz77Encoder, DefaultLz77EncoderBuilder};
use alloc::vec::Vec;
use core::cmp;
use core2::io;
use no_std_io2::io;
use rle_decode_fast::rle_decode;

mod default;
Expand Down Expand Up @@ -248,7 +248,7 @@ impl io::Read for Lz77Decoder {
mod tests {
use super::*;
use alloc::vec::Vec;
use core2::io::Read as _;
use no_std_io2::io::Read as _;

#[test]
fn encoder_and_decoder_works() {
Expand Down
4 changes: 2 additions & 2 deletions src/bit.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use core2::io;
use no_std_io2::io;

#[derive(Debug)]
pub struct BitWriter<W> {
Expand Down Expand Up @@ -177,7 +177,7 @@ pub(crate) struct BitReaderState {
mod tests {
use super::*;
use alloc::vec::Vec;
use core2::io;
use no_std_io2::io;

#[test]
fn writer_works() {
Expand Down
6 changes: 3 additions & 3 deletions src/deflate/decode.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::symbol;
use crate::bit;
use crate::lz77;
use core2::io::{self, Read};
use no_std_io2::io::{self, Read};

/// DEFLATE decoder.
#[derive(Debug)]
Expand All @@ -22,7 +22,7 @@ where
/// ```
/// # extern crate alloc;
/// # use alloc::vec::Vec;
/// use core2::io::{Cursor, Read};
/// use no_std_io2::io::{Cursor, Read};
/// use libflate::deflate::Decoder;
///
/// let encoded_data = [243, 72, 205, 201, 201, 87, 8, 207, 47, 202, 73, 81, 4, 0];
Expand Down Expand Up @@ -54,7 +54,7 @@ where
///
/// # Examples
/// ```
/// use core2::io::Cursor;
/// use no_std_io2::io::Cursor;
/// use libflate::deflate::Decoder;
///
/// let encoded_data = [243, 72, 205, 201, 201, 87, 8, 207, 47, 202, 73, 81, 4, 0];
Expand Down
10 changes: 5 additions & 5 deletions src/deflate/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::finish::{Complete, Finish};
use crate::lz77;
use alloc::vec::Vec;
use core::cmp;
use core2::io;
use no_std_io2::io;

/// The default size of a DEFLATE block.
pub const DEFAULT_BLOCK_SIZE: usize = 1024 * 1024;
Expand Down Expand Up @@ -143,7 +143,7 @@ where
///
/// # Examples
/// ```
/// use core2::io::Write;
/// use no_std_io2::io::Write;
/// use libflate::deflate::Encoder;
///
/// let mut encoder = Encoder::new(Vec::new());
Expand All @@ -168,7 +168,7 @@ where
///
/// # Examples
/// ```
/// use core2::io::Write;
/// use no_std_io2::io::Write;
/// use libflate::deflate::{Encoder, EncodeOptions};
///
/// let options = EncodeOptions::new().no_compression();
Expand All @@ -190,7 +190,7 @@ where
///
/// # Examples
/// ```
/// use core2::io::Write;
/// use no_std_io2::io::Write;
/// use libflate::deflate::Encoder;
///
/// let mut encoder = Encoder::new(Vec::new());
Expand Down Expand Up @@ -429,7 +429,7 @@ where
mod tests {
use super::super::Decoder;
use super::*;
use core2::io::{Read as _, Write as _};
use no_std_io2::io::{Read as _, Write as _};

#[test]
fn test_issues_52() {
Expand Down
4 changes: 2 additions & 2 deletions src/deflate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//!
//! # Examples
//! ```
//! use core2::io::{Read, Write};
//! use no_std_io2::io::{Read, Write};
//! use libflate::deflate::{Encoder, Decoder};
//!
//! // Encoding
Expand Down Expand Up @@ -43,7 +43,7 @@ mod tests {
use super::*;
use crate::lz77;
use alloc::vec::Vec;
use core2::io::{Read, Write};
use no_std_io2::io::{Read, Write};

#[test]
fn encode_and_decode_works() {
Expand Down
2 changes: 1 addition & 1 deletion src/deflate/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::huffman::Builder;
use crate::lz77;
use alloc::{boxed::Box, vec::Vec};
use core::{cmp, iter, ops::Range};
use core2::io;
use no_std_io2::io;

const FIXED_LITERAL_OR_LENGTH_CODE_TABLE: [(u8, Range<u16>, u16); 4] = [
(8, 000..144, 0b0_0011_0000),
Expand Down
6 changes: 3 additions & 3 deletions src/finish.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! `Finish` and related types.

use core::ops::{Deref, DerefMut};
use core2::io::{self, Write};
use no_std_io2::io::{self, Write};

/// `Finish` is a type that represents a value which
/// may have an error occurred during the computation.
Expand Down Expand Up @@ -105,7 +105,7 @@ impl<T: Complete> AutoFinish<T> {
/// # Examples
///
/// ```
/// use core2::io::Write;
/// use no_std_io2::io::Write;
/// use libflate::finish::AutoFinish;
/// use libflate::gzip::Encoder;
///
Expand Down Expand Up @@ -167,7 +167,7 @@ impl<T: Complete> AutoFinishUnchecked<T> {
/// # Examples
///
/// ```
/// use core2::io::Write;
/// use no_std_io2::io::Write;
/// use libflate::finish::AutoFinishUnchecked;
/// use libflate::gzip::Encoder;
///
Expand Down
22 changes: 11 additions & 11 deletions src/gzip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//!
//! # Examples
//! ```
//! use core2::io::{Read, Write};
//! use no_std_io2::io::{Read, Write};
//! use libflate::gzip::{Encoder, Decoder};
//!
//! // Encoding
Expand All @@ -24,7 +24,7 @@ use crate::deflate;
use crate::finish::{Complete, Finish};
use crate::lz77;
use alloc::{ffi::CString, vec::Vec};
use core2::io;
use no_std_io2::io;
#[cfg(feature = "std")]
use std::time;

Expand Down Expand Up @@ -767,7 +767,7 @@ where
///
/// # Examples
/// ```
/// use core2::io::Write;
/// use no_std_io2::io::Write;
/// use libflate::gzip::Encoder;
///
/// let mut encoder = Encoder::new(Vec::new()).unwrap();
Expand All @@ -789,7 +789,7 @@ where
///
/// # Examples
/// ```
/// use core2::io::Write;
/// use no_std_io2::io::Write;
/// use libflate::gzip::{Encoder, EncodeOptions, HeaderBuilder};
///
/// let header = HeaderBuilder::new().modification_time(123).finish();
Expand Down Expand Up @@ -828,7 +828,7 @@ where
///
/// # Examples
/// ```
/// use core2::io::Write;
/// use no_std_io2::io::Write;
/// use libflate::gzip::Encoder;
///
/// let mut encoder = Encoder::new(Vec::new()).unwrap();
Expand All @@ -843,7 +843,7 @@ where
/// it may be convenient to use `AutoFinishUnchecked` instead of the explicit invocation of this method.
///
/// ```
/// use core2::io::Write;
/// use no_std_io2::io::Write;
/// use libflate::finish::AutoFinishUnchecked;
/// use libflate::gzip::Encoder;
///
Expand Down Expand Up @@ -925,7 +925,7 @@ where
///
/// # Examples
/// ```
/// use core2::io::Read;
/// use no_std_io2::io::Read;
/// use libflate::gzip::Decoder;
///
/// let encoded_data = [31, 139, 8, 0, 123, 0, 0, 0, 0, 3, 1, 12, 0, 243, 255,
Expand Down Expand Up @@ -974,7 +974,7 @@ where
///
/// # Examples
/// ```
/// use core2::io::Cursor;
/// use no_std_io2::io::Cursor;
/// use libflate::gzip::Decoder;
///
/// let encoded_data = [31, 139, 8, 0, 123, 0, 0, 0, 0, 3, 1, 12, 0, 243, 255,
Expand Down Expand Up @@ -1063,7 +1063,7 @@ where
///
/// # Examples
/// ```
/// use core2::io::Read;
/// use no_std_io2::io::Read;
/// use libflate::gzip::MultiDecoder;
///
/// let mut encoded_data = Vec::new();
Expand Down Expand Up @@ -1121,7 +1121,7 @@ where
///
/// # Examples
/// ```
/// use core2::io::Cursor;
/// use no_std_io2::io::Cursor;
/// use libflate::gzip::MultiDecoder;
///
/// let encoded_data = [31, 139, 8, 0, 123, 0, 0, 0, 0, 3, 1, 12, 0, 243, 255,
Expand Down Expand Up @@ -1171,7 +1171,7 @@ mod tests {
use super::*;
use crate::finish::AutoFinish;
use alloc::{vec, vec::Vec};
use core2::io::{Read, Write};
use no_std_io2::io::{Read, Write};

fn decode(buf: &[u8]) -> io::Result<Vec<u8>> {
let mut decoder = Decoder::new(buf).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/huffman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use crate::bit;
use alloc::{vec, vec::Vec};
use core::cmp;
use core2::io;
use no_std_io2::io;

const MAX_BITWIDTH: u8 = 15;

Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ extern crate alloc;

macro_rules! invalid_data_error {
($fmt:expr) => {
::core2::io::Error::new(::core2::io::ErrorKind::InvalidData, $fmt)
::no_std_io2::io::Error::new(::no_std_io2::io::ErrorKind::InvalidData, $fmt)
};
($fmt:expr, $($arg:tt)*) => {
{
#[cfg(feature = "std")]
{
::core2::io::Error::new(
::core2::io::ErrorKind::InvalidData,
::no_std_io2::io::Error::new(
::no_std_io2::io::ErrorKind::InvalidData,
::alloc::format!($fmt, $($arg)*),
)
}
#[cfg(not(feature = "std"))]
{
::core2::io::Error::new(::core2::io::ErrorKind::InvalidData, $fmt)
::no_std_io2::io::Error::new(::no_std_io2::io::ErrorKind::InvalidData, $fmt)
}
}
};
Expand Down
8 changes: 4 additions & 4 deletions src/non_blocking/deflate/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::deflate::symbol::{self, HuffmanCodec};
use crate::lz77;
use crate::non_blocking::transaction::TransactionalBitReader;
use core::cmp;
use core2::io::{self, Read};
use no_std_io2::io::{self, Read};
/// DEFLATE decoder which supports non-blocking I/O.
#[derive(Debug)]
pub struct Decoder<R> {
Expand All @@ -18,7 +18,7 @@ impl<R: Read> Decoder<R> {
///
/// # Examples
/// ```
/// use core2::io::{Cursor, Read};
/// use no_std_io2::io::{Cursor, Read};
/// use libflate::non_blocking::deflate::Decoder;
///
/// let encoded_data = [243, 72, 205, 201, 201, 87, 8, 207, 47, 202, 73, 81, 4, 0];
Expand Down Expand Up @@ -51,7 +51,7 @@ impl<R: Read> Decoder<R> {
///
/// # Examples
/// ```
/// use core2::io::Cursor;
/// use no_std_io2::io::Cursor;
/// use libflate::non_blocking::deflate::Decoder;
///
/// let encoded_data = [243, 72, 205, 201, 201, 87, 8, 207, 47, 202, 73, 81, 4, 0];
Expand Down Expand Up @@ -242,7 +242,7 @@ mod tests {
use crate::deflate::{EncodeOptions, Encoder};
use crate::util::{WouldBlockReader, nb_read_to_end};
use alloc::{format, string::String, vec::Vec};
use core2::io::{Read, Write};
use no_std_io2::io::{Read, Write};

#[test]
fn it_works() {
Expand Down
2 changes: 1 addition & 1 deletion src/non_blocking/deflate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//!
//! # Examples
//! ```
//! use core2::io::{Read, Write};
//! use no_std_io2::io::{Read, Write};
//! use libflate::deflate::Encoder;
//! use libflate::non_blocking::deflate::Decoder;
//!
Expand Down
Loading