Giter VIP home page Giter VIP logo

bzip3-rs's Introduction

bzip3-rs's People

Contributors

bczhc avatar marcospb19 avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

marcospb19

bzip3-rs's Issues

Error with chained decoders

One reproducible example:

use std::fs::File;
use std::io;
use std::io::sink;

fn main() {
    let file = "/home/bczhc/t/2/file.sz.xz.bz3";

    let source = File::open(file).unwrap();

    let bz3_decoder = bzip3::read::Bz3Decoder::new(source).unwrap();
    let mut decoder = xz2::read::XzDecoder::new(bz3_decoder);

    // thread 'main' panicked at examples/bug.rs:13:41:
    // called `Result::unwrap()` on an `Err` value: Custom { kind: UnexpectedEof, error: "premature eof" }
    // ...
    io::copy(&mut decoder, &mut sink()).unwrap();
}

`Bz3Encoder` and `Bz3Decoder` do not implement `Send` and `Sync`

I believe it should be safe to send (Send) bz3 encoder and decoders between different threads, as well as sharing immutable references (Sync).

For reference, here's the bzip2 code:

https://github.com/alexcrichton/bzip2-rs/blob/3032f3790742bffda521e54d14429f459e078eba/src/mem.rs#L13-L35

The type Stream implements Send and Sync so all decoders and encoders all auto-impl them too.

This is currently a blocker for #1, adding these lines was enough for me to make it work :) .

unsafe impl<W: std::io::Write> Send for Bz3Encoder<W> {}
unsafe impl<R: std::io::Read> Send for Bz3Decoder<R> {}

Adding support for `bzip3` in `Ouch`

Hey!

I'd love to use this to add bzip3 support to Ouch.

It's a fairly new crate, so I wanted to politely ask if you'd trust its current state, Ouch is shipped to a couple of distros so I just wanna be a bit cautious and hear from you if you'd trust it as it is right now, or if I need to wait, idk.

Also, do you need any help with any specific issue right now? I'm willing to help :) .

Redundant empty blocks are present

An empty block is 080000000000000001000000ffffffff;

let mut buf = Vec::new();
    let encoder = write::Bz3Encoder::new(&mut buf, 16 * MIB as usize).unwrap();
    drop(encoder);
    println!("{}", hex::encode(buf));

should output 425a33763100000001 but not 425a33763100000001 080000000000000001000000ffffffff.

Same:

let mut buf = Vec::new();
    let mut encoder = write::Bz3Encoder::new(&mut buf, 16 * MIB as usize).unwrap();
    encoder.flush().unwrap();
    encoder.write_all(b"hello").unwrap();
    drop(encoder);
    println!("{}", hex::encode(&buf));

VS.

let mut buf = Vec::new();
    let mut encoder = write::Bz3Encoder::new(&mut buf, 16 * MIB as usize).unwrap();
    // encoder.flush().unwrap();
    encoder.write_all(b"hello").unwrap();
    drop(encoder);
    println!("{}", hex::encode(&buf));

The outputs of these two should be identical.

API suggestion: Move `Error` to crate root

Taking serde_json as an example, it seems good to have Error and Result at the root of your crate so users can refer to it as bzip3::Error and bzip3::Result.

They can be a link to bzip3::error::*, but I don't think it's strictly necessary to have the explicit module exposed in your API.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.