From 3533adf0580b05bca87fd7bd77a0384e9ecff9f2 Mon Sep 17 00:00:00 2001 From: Rob Parrett <robparrett@gmail.com> Date: Fri, 1 Jan 2021 00:33:21 -0700 Subject: [PATCH] Feature-gate zstd so we can target wasm32-unknown-unknown --- Cargo.toml | 5 ++++- src/lib.rs | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 41faefd..1a064b8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,9 @@ edition = "2018" keywords = ["tiled", "tmx", "map"] +[features] +default = ["zstd"] + [lib] name = "tiled" path = "src/lib.rs" @@ -24,4 +27,4 @@ path = "examples/main.rs" base64 = "0.10" xml-rs = "0.8" libflate = "0.1.18" -zstd = "0.5" +zstd = { version = "0.5", optional = true } diff --git a/src/lib.rs b/src/lib.rs index 3d466ed..fe2a6f3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1131,6 +1131,7 @@ fn parse_data_line<R: Read>(encoding: Option<String>, compression: Option<String .and_then(decode_gzip) .map(|v| convert_to_tile(&v, width)) } + #[cfg(feature = "zstd")] ("base64", "zstd") => { return parse_base64(parser) .and_then(decode_zstd) @@ -1186,6 +1187,7 @@ fn decode_gzip(data: Vec<u8>) -> Result<Vec<u8>, TiledError> { Ok(data) } +#[cfg(feature = "zstd")] fn decode_zstd(data: Vec<u8>) -> Result<Vec<u8>, TiledError> { use std::io::Cursor; use zstd::stream::read::Decoder; -- GitLab