From 1dbd6689017efab66b8c530a194da70840839112 Mon Sep 17 00:00:00 2001 From: Ilia Konnov Date: Wed, 27 Jul 2022 02:02:44 +0300 Subject: [PATCH] serde: implement `AsSerde` for `FieldSet` (#2241) ## Motivation I've wanted to serialize fieldset of current span. ## Solution Expose already existing `SerializeFieldSet` for users by implementing `AsSerde` for `FieldSet`. --- tracing-serde/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tracing-serde/src/lib.rs b/tracing-serde/src/lib.rs index 3df9114f0a..f099853ec0 100644 --- a/tracing-serde/src/lib.rs +++ b/tracing-serde/src/lib.rs @@ -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> {} @@ -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 {} }