Skip to content

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
rukai committed Mar 22, 2023
1 parent 1b0d414 commit 9ed3fe1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions shotover-proxy/src/config/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,25 @@ impl TransformChainConfig {
}
}

/// This function is a custom deserializer that works around a mismatch in the way yaml and typetag represent things,
/// resulting in typetagged structs with no fields failing to deserialize from a single line yaml entry.
/// e.g. with typetag + yaml + the default serializer:
/// this would fail to deserialize:
/// ```yaml
/// chain_config:
/// redis_chain:
/// - NullSink
/// ```
///
/// but this would work fine:
/// ```yaml
/// chain_config:
/// redis_chain:
/// - NullSink: {}
/// ```
///
/// With the use of this custom deserializer both cases now deserialize correctly.
/// The implementation was a suggestion from dtolnay: https://github.com/dtolnay/typetag/pull/40#issuecomment-1454961686
fn vec_transform_config<'de, D>(deserializer: D) -> Result<Vec<Box<dyn TransformConfig>>, D::Error>
where
D: Deserializer<'de>,
Expand Down

0 comments on commit 9ed3fe1

Please sign in to comment.