Extract lzma file

#1

Hello, I’m trying to use curl and xz2 to download and extract lzma file.
Program panic at decompressor.read_to_end(&mut buf).unwrap(); and I’m don’t know how to fix it. data parameter in the closure is byte array.

thread 'main' panicked at 'calledResult::unwrap()on anErrvalue: Custom { kind: Other, error: Format }', src/libcore/result.rs:997:5

use curl::easy::Easy;
use std::io::prelude::*;
use xz2::read::XzDecoder;
use std::fs::File;

fn main() {
    let mut easy = Easy::new();
    easy.url("https://datafeed.dukascopy.com/datafeed/EURUSD/2003/04/BID_candles_hour_1.bi5")
        .unwrap();
    easy.write_function(|data| {
        let mut decompressor = XzDecoder::new(data);
        let mut buf = vec![];
        decompressor.read_to_end(&mut buf).unwrap();
        println!("{}", data.len());
        Ok(data.len())
    })
    .unwrap();
    easy.perform().unwrap();
}

Edit: I just found out my file format is legacy LZMA, xz2 crate only support LZMA2.