You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
538 B
22 lines
538 B
use super::extract::{Error, Extract}; |
|
use std::{io::Read, path::Path}; |
|
|
|
pub struct TarXz<R: Read> { |
|
response: R, |
|
} |
|
|
|
impl<R: Read> TarXz<R> { |
|
#[allow(dead_code)] |
|
pub fn new(response: R) -> Self { |
|
Self { response } |
|
} |
|
} |
|
|
|
impl<R: Read> Extract for TarXz<R> { |
|
fn extract_into<P: AsRef<Path>>(self, path: P) -> Result<(), Error> { |
|
let xz_stream = xz2::read::XzDecoder::new(self.response); |
|
let mut tar_archive = tar::Archive::new(xz_stream); |
|
tar_archive.unpack(&path)?; |
|
Ok(()) |
|
} |
|
}
|
|
|