diff --git a/src/api/data_types/chunking/compression.rs b/src/api/data_types/chunking/compression.rs index 7bb1a1eadb..6c0660c802 100644 --- a/src/api/data_types/chunking/compression.rs +++ b/src/api/data_types/chunking/compression.rs @@ -1,16 +1,18 @@ use std::fmt; -use serde::{Deserialize, Deserializer}; +use serde::Deserialize; -#[derive(Debug, Clone, Copy, Ord, PartialOrd, Eq, PartialEq, Default)] +#[derive(Debug, Clone, Copy, Ord, PartialOrd, Eq, PartialEq, Default, Deserialize)] +#[serde(rename_all = "lowercase")] pub enum ChunkCompression { - /// No compression should be applied - #[default] - Uncompressed = 0, /// GZIP compression (including header) Gzip = 10, /// Brotli compression Brotli = 20, + /// No compression should be applied + #[default] + #[serde(other)] + Uncompressed = 0, } impl ChunkCompression { @@ -32,17 +34,3 @@ impl fmt::Display for ChunkCompression { } } } - -impl<'de> Deserialize<'de> for ChunkCompression { - fn deserialize(deserializer: D) -> Result - where - D: Deserializer<'de>, - { - Ok(match String::deserialize(deserializer)?.as_str() { - "gzip" => ChunkCompression::Gzip, - "brotli" => ChunkCompression::Brotli, - // We do not know this compression, so we assume no compression - _ => ChunkCompression::Uncompressed, - }) - } -}