From d33ec3e6028134dd0d13d9e23aa2225e3546bcba Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Mon, 13 Nov 2023 14:47:01 +0100 Subject: [PATCH 1/2] Do not pub-import the `NoExtraKeys` name. It's publicly accessible through `glean::traits` instead. --- glean-core/rlb/src/private/event.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/glean-core/rlb/src/private/event.rs b/glean-core/rlb/src/private/event.rs index d646ec3eb6..f597b854af 100644 --- a/glean-core/rlb/src/private/event.rs +++ b/glean-core/rlb/src/private/event.rs @@ -9,8 +9,6 @@ use glean_core::traits; use crate::{ErrorType, RecordedEvent}; -pub use glean_core::traits::NoExtraKeys; - // We need to wrap the glean-core type: otherwise if we try to implement // the trait for the metric in `glean_core::metrics` we hit error[E0117]: // only traits defined in the current crate can be implemented for arbitrary @@ -70,7 +68,7 @@ mod test { let _lock = lock_test(); let _t = new_glean(None, true); - let metric: EventMetric = EventMetric::new(CommonMetricData { + let metric: EventMetric = EventMetric::new(CommonMetricData { name: "event".into(), category: "test".into(), send_in_pings: vec!["test1".into()], From 4fb4b3b3d88f64beb6975a3612f0c19ae45764fd Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Mon, 13 Nov 2023 14:47:33 +0100 Subject: [PATCH 2/2] Move tests to the end of the file --- glean-core/rlb/src/private/event.rs | 50 ++++++++++++++--------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/glean-core/rlb/src/private/event.rs b/glean-core/rlb/src/private/event.rs index f597b854af..8b1abca84f 100644 --- a/glean-core/rlb/src/private/event.rs +++ b/glean-core/rlb/src/private/event.rs @@ -57,6 +57,31 @@ impl EventMetric { } } +#[inherent] +impl traits::Event for EventMetric { + type Extra = K; + + pub fn record::Extra>>>(&self, extra: M) { + let extra = extra + .into() + .map(|e| e.into_ffi_extra()) + .unwrap_or_else(HashMap::new); + self.inner.record(extra); + } + + pub fn test_get_value<'a, S: Into>>( + &self, + ping_name: S, + ) -> Option> { + let ping_name = ping_name.into().map(|s| s.to_string()); + self.inner.test_get_value(ping_name) + } + + pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 { + self.inner.test_get_num_recorded_errors(error) + } +} + #[cfg(test)] mod test { use super::*; @@ -194,28 +219,3 @@ mod test { assert_eq!(None, data[2].extra); } } - -#[inherent] -impl traits::Event for EventMetric { - type Extra = K; - - pub fn record::Extra>>>(&self, extra: M) { - let extra = extra - .into() - .map(|e| e.into_ffi_extra()) - .unwrap_or_else(HashMap::new); - self.inner.record(extra); - } - - pub fn test_get_value<'a, S: Into>>( - &self, - ping_name: S, - ) -> Option> { - let ping_name = ping_name.into().map(|s| s.to_string()); - self.inner.test_get_value(ping_name) - } - - pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 { - self.inner.test_get_num_recorded_errors(error) - } -}