diff --git a/Cargo.toml b/Cargo.toml index 41faefd09bb1185b64a21d3d98f3c87850e9e615..1a064b8091eca01ec0bb2bbc64f30d147a4981e4 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 3d466ed23b0b071e4bd091467f6220d09c3dbfa1..fe2a6f3ba5f061258f2c9f7f44b3fe147cc37722 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;