Skip to content

Commit

Permalink
serde: implement AsSerde for FieldSet (#2241)
Browse files Browse the repository at this point in the history
## Motivation

I've wanted to serialize fieldset of current span.

## Solution

Expose already existing `SerializeFieldSet` for users by implementing `AsSerde` for `FieldSet`.
  • Loading branch information
iliakonnov committed Jul 26, 2022
1 parent 876fe1f commit 497f668
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tracing-serde/src/lib.rs
Expand Up @@ -533,6 +533,14 @@ impl<'a> AsSerde<'a> for Level {
}
}

impl<'a> AsSerde<'a> for FieldSet {
type Serializable = SerializeFieldSet<'a>;

fn as_serde(&'a self) -> Self::Serializable {
SerializeFieldSet(self)
}
}

impl<'a> self::sealed::Sealed for Event<'a> {}

impl<'a> self::sealed::Sealed for Attributes<'a> {}
Expand All @@ -545,6 +553,8 @@ impl<'a> self::sealed::Sealed for Record<'a> {}

impl<'a> self::sealed::Sealed for Metadata<'a> {}

impl self::sealed::Sealed for FieldSet {}

mod sealed {
pub trait Sealed {}
}

0 comments on commit 497f668

Please sign in to comment.