Skip to content

Commit

Permalink
Merge pull request #2 from chalharu/add-bzip2
Browse files Browse the repository at this point in the history
Add bzip2, defalte, gzip, zlib, lzhuf
  • Loading branch information
chalharu committed Mar 22, 2018
2 parents db198b7 + 3ced01a commit 0ee15b2
Show file tree
Hide file tree
Showing 61 changed files with 40,728 additions and 28 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
build
Cargo.lock
target
*.bk
.DS_Store
*.swp

52 changes: 35 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ rust:
- beta
- nightly

sudo: false
sudo: true

os:
- linux
Expand All @@ -22,23 +22,13 @@ addons:
- libdw-dev
- binutils-dev
- libiberty-dev
- cmake

before_script:
- |
if [ "${TRAVIS_OS_NAME}" = 'osx' ]; then
export PATH=$HOME/Library/Python/2.7/bin:$PATH
fi
- |
if [ "${TRAVIS_OS_NAME}" = "linux" ]; then
cargo install cargo-kcov
if [ ! -x $HOME/.cargo/bin/kcov ] || [ ! -f $HOME/.cargo/bin/kcov ]; then
mkdir kcov
cd kcov
cargo kcov --print-install-kcov-sh | sh
cd ${TRAVIS_BUILD_DIR}
rm -rf kcov
fi
fi
- |
if [ "${TRAVIS_OS_NAME}" = "linux" ]; then
pippackage=("ghp-import" "pytoml")
Expand All @@ -48,22 +38,49 @@ before_script:
fi
- |
if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then
export FEATURES=""
export FEATURES="all"
else
export FEATURES=""
export FEATURES="all"
fi
- cargo install cargo-update || echo "cargo-update already installed"
- cargo install cargo-travis || echo "cargo-travis already installed"
- cargo install-update -a || true # update outdated cached binaries

script:
- cargo build --features="$FEATURES"
- cargo test --no-run --features="$FEATURES"
- cargo build --release --features="$FEATURES"
- cargo test --release --no-run --features="$FEATURES"
- |
if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then
cargo build --no-default-features --features="$FEATURES"
cargo test --no-run --no-default-features --features="$FEATURES"
cargo build --release --no-default-features --features="$FEATURES"
cargo test --release --no-run --no-default-features --features="$FEATURES"
fi
- |
if [ "${TRAVIS_OS_NAME}" = "linux" ]; then
cargo kcov --coveralls --features="$FEATURES"
cargo coveralls --features="$FEATURES" ||
cargo coveralls ||
cargo test --features="$FEATURES"
else
cargo test --features="$FEATURES"
fi
- |
if [ "${TRAVIS_OS_NAME}" = "linux" ]; then
if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then
cargo coveralls --no-default-features --features="$FEATURES" ||
cargo test --no-default-features --features="$FEATURES"
fi
else
if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then
cargo test --no-default-features --features="$FEATURES"
fi
fi
- |
if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then
cargo test --release --no-default-features --features="$FEATURES"
fi
- cargo test --release --features="$FEATURES"
- |
if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then
Expand All @@ -86,7 +103,8 @@ after_success:
if [ "${TRAVIS_OS_NAME}" = "linux" ] &&
[ "${TRAVIS_RUST_VERSION}" = "stable" ] &&
[ "${TRAVIS_BRANCH}" = "master" ] &&
[ "${TRAVIS_PULL_REQUEST}" = "false" ]; then
[ "${TRAVIS_PULL_REQUEST}" = "false" ] &&
[ "${TRAVIS_EVENT_TYPE}" = "push" ]; then
git push -fq https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages &&
cargo publish
fi
Expand All @@ -103,4 +121,4 @@ cache:
notifications:
email:
on_success: never
on_failure: always
on_failure: always
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "lldb",
"request": "launch",
"name": "Debug Test",
"program": "${workspaceRoot}/target/debug/deps/lib-47666649066c41e9",
"program": "${workspaceRoot}/target/debug/deps/compression-33f748de75300242",
"args": [
"--nocapture"
],
Expand All @@ -30,4 +30,4 @@
"internalConsoleOptions": "openOnSessionStart"
}
]
}
}
22 changes: 19 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "rust-compression"
name = "compression"
version = "0.1.0"
authors = ["Mitsuharu Seki <mitsu1986@gmail.com>"]
repository = "https://github.com/chalharu/rust-compression"
keywords = ["compress", "gzip", "flate", "deflate", "bzip2", "lzh"]
keywords = ["compress", "gzip", "flate", "deflate", "bzip2", "lzh", "no_std"]
license = "MPL-2.0"
readme = "README.md"
description = "Compression libraries implemented by pure Rust."
Expand All @@ -15,11 +15,27 @@ bench = false
test = true

[dependencies]
clippy = { version = ">=0.0.0", optional = true }
num-traits = { version = ">=0.2.0", default-features = false }
lazy_static = ">0.0.0"
log = { version = ">=0.0.0", default-features = false }
cfg-if = ">0.0.0"

[dev-dependencies]
simple_logger = { version = ">=0.0.0" }
rand = ">=0.0.0"

[features]
docs = []
default = [ "std", "bzip2", "gzip", "deflate", "zlib" ]
all = [ "bzip2", "gzip", "deflate", "zlib", "lzhuf" ]
bzip2 = [ ]
lzhuf = [ ]
gzip = [ "deflate" ]
deflate = [ ]
zlib = [ "deflate" ]
std = [ ]
docs = [ "all" ]
lint = [ "clippy", "all" ]

[badges]
travis-ci = { repository = "chalharu/rust-compression" }
Expand Down
36 changes: 33 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,44 @@

Compression libraries implemented by pure Rust.

## How-to Use

See the [crate documentation](https://docs.rs/compression/) for more details.
```toml
[dependencies]
compression = "0.1"
```

## Features

- **`deflate`** - Enabled by default.

- **`gzip`** - Enabled by default.

- **`zlib`** - Enabled by default.

- **`bzip2`** - Enabled by default.

- **`lzhuf`** - Disabled by default.

- **`std`** - By default, `compression` depends on libstd. However, it can be configured to use the unstable liballoc API instead, for use on platforms that have liballoc but not libstd. This configuration is currently unstable and is not guaranteed to work on all versions of Rust. To depend on `compression` without libstd, use default-features = false in the `compression` section of Cargo.toml to disable its "std" feature.

### Examples

```rust
extern crate compression;
use compression::prelude::*;

fn main() {
let compressed = b"aabbaabbaabbaabb\n"
.into_iter()
.cloned()
.encode(&mut BZip2Encoder::new(9), Action::Finish)
.collect::<Result<Vec<_>, _>>()
.unwrap();

let decompressed = compressed
.iter()
.cloned()
.decode(&mut BZip2Decoder::new())
.collect::<Result<Vec<_>, _>>()
.unwrap();
}
```
Binary file added data/sample1.bz2
Binary file not shown.
Binary file added data/sample1.ref
Binary file not shown.
Binary file added data/sample2.bz2
Binary file not shown.
Binary file added data/sample2.ref
Binary file not shown.
Binary file added data/sample3.bz2
Binary file not shown.

0 comments on commit 0ee15b2

Please sign in to comment.