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 authored and hawkw committed Jul 29, 2022
1 parent a0824d3 commit 27ffce2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tracing-serde/src/lib.rs
Expand Up @@ -565,6 +565,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 @@ -577,6 +585,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 27ffce2

Please sign in to comment.