Remove the last bits of unknown_os in the code base (#9718)

* Remove the last bits of unknown_os in the code base

* Fmt
This commit is contained in:
Bastian Köcher
2021-09-09 11:17:16 +02:00
committed by GitHub
parent a443944167
commit 129c9ed09e
28 changed files with 197 additions and 523 deletions
@@ -10,8 +10,5 @@ description = "Handling of blobs, usually Wasm code, which may be compresed"
documentation = "https://docs.rs/sp-maybe-compressed-blob"
readme = "README.md"
[target.'cfg(not(target_os = "unknown"))'.dependencies]
[dependencies]
zstd = { version = "0.6.0", default-features = false }
[target.'cfg(target_os = "unknown")'.dependencies]
ruzstd = { version = "0.2.2" }
@@ -70,22 +70,12 @@ fn read_from_decoder(
}
}
#[cfg(not(target_os = "unknown"))]
fn decompress_zstd(blob: &[u8], bomb_limit: usize) -> Result<Vec<u8>, Error> {
let decoder = zstd::Decoder::new(blob).map_err(|_| Error::Invalid)?;
read_from_decoder(decoder, blob.len(), bomb_limit)
}
#[cfg(target_os = "unknown")]
fn decompress_zstd(mut blob: &[u8], bomb_limit: usize) -> Result<Vec<u8>, Error> {
let blob_len = blob.len();
let decoder =
ruzstd::streaming_decoder::StreamingDecoder::new(&mut blob).map_err(|_| Error::Invalid)?;
read_from_decoder(decoder, blob_len, bomb_limit)
}
/// Decode a blob, if it indicates that it is compressed. Provide a `bomb_limit`, which
/// is the limit of bytes which should be decompressed from the blob.
pub fn decompress(blob: &[u8], bomb_limit: usize) -> Result<Cow<[u8]>, Error> {
@@ -99,7 +89,6 @@ pub fn decompress(blob: &[u8], bomb_limit: usize) -> Result<Cow<[u8]>, Error> {
/// Encode a blob as compressed. If the blob's size is over the bomb limit,
/// this will not compress the blob, as the decoder will not be able to be
/// able to differentiate it from a compression bomb.
#[cfg(not(target_os = "unknown"))]
pub fn compress(blob: &[u8], bomb_limit: usize) -> Option<Vec<u8>> {
use std::io::Write;