Giter VIP home page Giter VIP logo

Comments (4)

alexcrichton avatar alexcrichton commented on May 29, 2024

Do you have some example data that I could test out on? There should be quite a bit of error checking internally, but there may perhaps be a bug here or there.

from flate2-rs.

SethDusek avatar SethDusek commented on May 29, 2024
extern crate flate2;

use std::io::prelude::*;
use flate2::read::ZlibDecoder;

fn main() {
    let mut d = ZlibDecoder::new("test".as_bytes());
    let mut string = String::new();
    d.read_to_string(&mut string);
    println!("Here's the data {}",&string); //print's Here's the data + blank
}

Unlike GzDecoder, ZlibDecoder::new() doesn't return a result and just returns the encoder, so you don't know whether it actually decoded

from flate2-rs.

alexcrichton avatar alexcrichton commented on May 29, 2024

Ah this is actually because the error is being ignored in this example. If you println!("{:?}", foo) the result of the read_to_string call you'll see:

Err(Error { repr: Custom(Custom { kind: InvalidInput, error: StringError("corrupt deflate stream") }) })

And during compilation you should also being seeing:

src/main.rs:9:5: 9:35 warning: unused result which must be used, #[warn(unused_must_use)] on by default
src/main.rs:9     d.read_to_string(&mut string);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'm gonna close this for now as it looks like the error is coming out ok, but let me know if you need any more help!

from flate2-rs.

SethDusek avatar SethDusek commented on May 29, 2024

Oh, thanks

from flate2-rs.

Related Issues (20)

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.