mirror of
https://github.com/Hopiu/lychee.git
synced 2026-04-23 22:44:47 +00:00
Fix JSON serialization (#426)
We recently removed the custom serialization for InputSource. This causes the JSON formatter to fail with "key must be a string". Add it back and add a comment on why this is needed.
This commit is contained in:
parent
18c606d2e8
commit
83182c29ca
1 changed files with 13 additions and 1 deletions
|
|
@ -43,7 +43,7 @@ impl InputContent {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
#[non_exhaustive]
|
||||
/// Input types which lychee supports
|
||||
pub enum InputSource {
|
||||
|
|
@ -64,6 +64,18 @@ pub enum InputSource {
|
|||
String(String),
|
||||
}
|
||||
|
||||
// Custom serialization for enum is needed
|
||||
// Otherwise we get "key must be a string" when using the JSON writer
|
||||
// Related: https://github.com/serde-rs/json/issues/45
|
||||
impl Serialize for InputSource {
|
||||
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
serializer.collect_str(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for InputSource {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_str(match self {
|
||||
|
|
|
|||
Loading…
Reference in a new issue