Skip to content

Commit

Permalink
Fix additional level of nesting that can not be flattened using serde
Browse files Browse the repository at this point in the history
Unfortunately, flattening enums with serde is blocked on
serde-rs/serde#1402.

Signed-off-by: Pablo Sichert <mail@pablosichert.com>
  • Loading branch information
pablosichert committed Feb 4, 2022
1 parent 496d1b4 commit 4e8a5e1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/codecs/encoding/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,17 @@ impl tokio_util::codec::Encoder<()> for Framer {
#[serde(tag = "codec", rename_all = "snake_case")]
pub enum SerializerConfig {
/// Configures the `JsonSerializer`.
Json(JsonSerializerConfig),
Json,
/// Configures the `RawMessageSerializer`.
RawMessage(RawMessageSerializerConfig),
RawMessage,
}

impl SerializerConfig {
/// Build the `Serializer` from this configuration.
pub const fn build(&self) -> Serializer {
match self {
SerializerConfig::Json(config) => Serializer::Json(config.build()),
SerializerConfig::RawMessage(config) => Serializer::RawMessage(config.build()),
SerializerConfig::Json => Serializer::Json(JsonSerializer::new()),
SerializerConfig::RawMessage => Serializer::RawMessage(RawMessageSerializer::new()),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/sinks/util/encoding/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ mod tests {
EncodingConfigAdapter::LegacyEncodingConfig(_) => panic!(),
};

assert!(matches!(encoding, SerializerConfig::RawMessage(_)));
assert!(matches!(encoding, SerializerConfig::RawMessage));
}

#[test]
Expand Down

0 comments on commit 4e8a5e1

Please sign in to comment.