Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Commit

Permalink
♻️ Make unpack_dvpl be async
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenein committed Jun 30, 2023
1 parent 707593c commit 8619c35
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/tankopedia/dvpl.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use anyhow::bail;
use byteorder::{LittleEndian, ReadBytesExt};
use lz4_flex::decompress;
use tokio::task::spawn_blocking;

use crate::prelude::*;

Expand All @@ -10,7 +11,9 @@ pub async fn unpack_dvpl(mut dvpl: Vec<u8>) -> Result<Vec<u8>> {
match footer.compression_type {
CompressionType::None => Ok(dvpl),
CompressionType::Lz4 | CompressionType::Lz4Hc => {
decompress(&dvpl, footer.uncompressed_size).context("failed to decompress LZ4")
spawn_blocking(move || decompress(&dvpl, footer.uncompressed_size))
.await?
.context("failed to decompress LZ4")
}
CompressionType::Rfc1951 => unimplemented!("RFC1951 is not implemented"),
}
Expand Down

0 comments on commit 8619c35

Please sign in to comment.