Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

[Full changelog](https://github.com/mozilla/glean/compare/v65.1.1...v65.2.0)

* Rust
* Rust: Use an associated type for `TestGetValue` ([#3259](https://github.com/mozilla/glean/pull/3259))
* Swift
* Glean for iOS is now being built with Xcode 16.2 ([#3189](https://github.com/mozilla/glean/pull/3189))
* General
Expand Down
4 changes: 3 additions & 1 deletion glean-core/rlb/src/private/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ impl<K: traits::ExtraKeys> EventMetric<K> {
}

#[inherent]
impl<K> TestGetValue<Vec<RecordedEvent>> for EventMetric<K> {
impl<K> TestGetValue for EventMetric<K> {
type Output = Vec<RecordedEvent>;

pub fn test_get_value(&self, ping_name: Option<String>) -> Option<Vec<RecordedEvent>> {
self.inner.test_get_value(ping_name)
}
Expand Down
4 changes: 3 additions & 1 deletion glean-core/rlb/src/private/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ impl<'a, K> MetricIdentifier<'a> for ObjectMetric<K> {
}
}

impl<K> TestGetValue<JsonValue> for ObjectMetric<K> {
impl<K> TestGetValue for ObjectMetric<K> {
type Output = JsonValue;

/// **Test-only API (exported for FFI purposes).**
///
/// Gets the currently stored value as JSON-encoded string.
Expand Down
3 changes: 2 additions & 1 deletion glean-core/src/metrics/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ impl BooleanMetric {
}
}

impl TestGetValue<bool> for BooleanMetric {
impl TestGetValue for BooleanMetric {
type Output = bool;
/// **Test-only API (exported for FFI purposes).**
///
/// Gets the currently stored value as a boolean.
Expand Down
4 changes: 3 additions & 1 deletion glean-core/src/metrics/counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ impl CounterMetric {
}
}

impl TestGetValue<i32> for CounterMetric {
impl TestGetValue for CounterMetric {
type Output = i32;

/// **Test-only API (exported for FFI purposes).**
///
/// Gets the currently stored value as an integer.
Expand Down
4 changes: 3 additions & 1 deletion glean-core/src/metrics/custom_distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,9 @@ impl CustomDistributionMetric {
}
}

impl TestGetValue<DistributionData> for CustomDistributionMetric {
impl TestGetValue for CustomDistributionMetric {
type Output = DistributionData;

/// **Test-only API (exported for FFI purposes).**
///
/// Gets the currently stored value as an integer.
Expand Down
4 changes: 3 additions & 1 deletion glean-core/src/metrics/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@ impl DatetimeMetric {
}
}

impl TestGetValue<Datetime> for DatetimeMetric {
impl TestGetValue for DatetimeMetric {
type Output = Datetime;

/// **Test-only API (exported for FFI purposes).**
///
/// Gets the stored datetime value.
Expand Down
4 changes: 3 additions & 1 deletion glean-core/src/metrics/denominator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ impl DenominatorMetric {
}
}

impl TestGetValue<i32> for DenominatorMetric {
impl TestGetValue for DenominatorMetric {
type Output = i32;

/// **Test-only API (exported for FFI purposes).**
///
/// Gets the currently stored value as an integer.
Expand Down
4 changes: 3 additions & 1 deletion glean-core/src/metrics/dual_labeled_counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ impl DualLabeledCounterMetric {
}
}

impl TestGetValue<HashMap<String, HashMap<String, i32>>> for DualLabeledCounterMetric {
impl TestGetValue for DualLabeledCounterMetric {
type Output = HashMap<String, HashMap<String, i32>>;

fn test_get_value(
&self,
ping_name: Option<String>,
Expand Down
4 changes: 3 additions & 1 deletion glean-core/src/metrics/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ impl EventMetric {
}
}

impl TestGetValue<Vec<RecordedEvent>> for EventMetric {
impl TestGetValue for EventMetric {
type Output = Vec<RecordedEvent>;

/// **Test-only API (exported for FFI purposes).**
///
/// Get the vector of currently stored events for this event metric.
Expand Down
6 changes: 4 additions & 2 deletions glean-core/src/metrics/labeled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,13 @@ where
}
}

impl<T, S> TestGetValue<HashMap<String, S>> for LabeledMetric<T>
impl<T, S> TestGetValue for LabeledMetric<T>
where
T: AllowLabeled + TestGetValue<S>,
T: AllowLabeled + TestGetValue<Output = S>,
S: Any,
{
type Output = HashMap<String, S>;

fn test_get_value(&self, ping_name: Option<String>) -> Option<HashMap<String, S>> {
let mut out = HashMap::new();
let map = self.label_map.lock().unwrap();
Expand Down
4 changes: 3 additions & 1 deletion glean-core/src/metrics/memory_distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,9 @@ impl MemoryDistributionMetric {
}
}

impl TestGetValue<DistributionData> for MemoryDistributionMetric {
impl TestGetValue for MemoryDistributionMetric {
type Output = DistributionData;

/// **Test-only API (exported for FFI purposes).**
///
/// Gets the currently stored value.
Expand Down
7 changes: 5 additions & 2 deletions glean-core/src/metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,10 @@ pub trait MetricIdentifier<'a> {
}

/// [`TestGetValue`] describes an interface for retrieving the value for a given metric
pub trait TestGetValue<T> {
pub trait TestGetValue {
/// The output type of `test_get_value`
type Output;

/// **Test-only API (exported for FFI purposes).**
///
/// Returns the currently stored value of the appropriate type for the given metric.
Expand All @@ -285,7 +288,7 @@ pub trait TestGetValue<T> {
/// # Returns
///
/// The stored value or `None` if nothing stored.
fn test_get_value(&self, ping_name: Option<String>) -> Option<T>;
fn test_get_value(&self, ping_name: Option<String>) -> Option<Self::Output>;
}

// Provide a blanket implementation for MetricIdentifier for all the types
Expand Down
4 changes: 3 additions & 1 deletion glean-core/src/metrics/numerator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ impl NumeratorMetric {
}
}

impl TestGetValue<Rate> for NumeratorMetric {
impl TestGetValue for NumeratorMetric {
type Output = Rate;

/// **Exported for test purposes.**
///
/// Gets the currently stored value as a pair of integers.
Expand Down
4 changes: 3 additions & 1 deletion glean-core/src/metrics/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ impl ObjectMetric {
}
}

impl TestGetValue<JsonValue> for ObjectMetric {
impl TestGetValue for ObjectMetric {
type Output = JsonValue;

/// **Test-only API (exported for FFI purposes).**
///
/// Gets the currently stored value as JSON.
Expand Down
4 changes: 3 additions & 1 deletion glean-core/src/metrics/quantity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ impl QuantityMetric {
}
}

impl TestGetValue<i64> for QuantityMetric {
impl TestGetValue for QuantityMetric {
type Output = i64;

/// **Test-only API (exported for FFI purposes).**
///
/// Gets the currently stored value as an integer.
Expand Down
4 changes: 3 additions & 1 deletion glean-core/src/metrics/rate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ impl RateMetric {
}
}

impl TestGetValue<Rate> for RateMetric {
impl TestGetValue for RateMetric {
type Output = Rate;

/// **Test-only API (exported for FFI purposes).**
///
/// Gets the currently stored value as a pair of integers.
Expand Down
4 changes: 3 additions & 1 deletion glean-core/src/metrics/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ impl StringMetric {
}
}

impl TestGetValue<String> for StringMetric {
impl TestGetValue for StringMetric {
type Output = String;

/// **Test-only API (exported for FFI purposes).**
///
/// Gets the currently stored value as a string.
Expand Down
4 changes: 3 additions & 1 deletion glean-core/src/metrics/string_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ impl StringListMetric {
}
}

impl TestGetValue<Vec<String>> for StringListMetric {
impl TestGetValue for StringListMetric {
type Output = Vec<String>;

/// **Test-only API (exported for FFI purposes).**
///
/// Gets the currently-stored values.
Expand Down
4 changes: 3 additions & 1 deletion glean-core/src/metrics/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ impl TextMetric {
}
}

impl TestGetValue<String> for TextMetric {
impl TestGetValue for TextMetric {
type Output = String;

/// **Test-only API (exported for FFI purposes).**
///
/// Gets the currently stored value as a string.
Expand Down
3 changes: 2 additions & 1 deletion glean-core/src/metrics/timespan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ impl TimespanMetric {
}
}

impl TestGetValue<i64> for TimespanMetric {
impl TestGetValue for TimespanMetric {
type Output = i64;
/// **Test-only API (exported for FFI purposes).**
///
/// Gets the currently stored value as an integer.
Expand Down
4 changes: 3 additions & 1 deletion glean-core/src/metrics/timing_distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,9 @@ impl TimingDistributionMetric {
}
}

impl TestGetValue<DistributionData> for TimingDistributionMetric {
impl TestGetValue for TimingDistributionMetric {
type Output = DistributionData;

/// **Test-only API (exported for FFI purposes).**
///
/// Gets the currently stored value as an integer.
Expand Down
4 changes: 3 additions & 1 deletion glean-core/src/metrics/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ impl UrlMetric {
}
}

impl TestGetValue<String> for UrlMetric {
impl TestGetValue for UrlMetric {
type Output = String;

/// **Test-only API (exported for FFI purposes).**
///
/// Gets the currently stored value as a string.
Expand Down
4 changes: 3 additions & 1 deletion glean-core/src/metrics/uuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ impl UuidMetric {
}
}

impl TestGetValue<String> for UuidMetric {
impl TestGetValue for UuidMetric {
type Output = String;

/// **Test-only API (exported for FFI purposes).**
///
/// Gets the currently stored value as a string.
Expand Down
2 changes: 1 addition & 1 deletion glean-core/src/traits/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{ErrorType, TestGetValue};
///
/// When changing this trait, make sure all the operations are
/// implemented in the related type in `../metrics/`.
pub trait Boolean: TestGetValue<bool> {
pub trait Boolean: TestGetValue<Output = bool> {
/// Sets to the specified boolean value.
///
/// # Arguments
Expand Down
2 changes: 1 addition & 1 deletion glean-core/src/traits/counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{ErrorType, TestGetValue};
///
/// When changing this trait, make sure all the operations are
/// implemented in the related type in `../metrics/`.
pub trait Counter: TestGetValue<i32> {
pub trait Counter: TestGetValue<Output = i32> {
/// Increases the counter by `amount`.
///
/// # Arguments
Expand Down
2 changes: 1 addition & 1 deletion glean-core/src/traits/custom_distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{DistributionData, ErrorType, TestGetValue};
///
/// When changing this trait, make sure all the operations are
/// implemented in the related type in `../metrics/`.
pub trait CustomDistribution: TestGetValue<DistributionData> {
pub trait CustomDistribution: TestGetValue<Output = DistributionData> {
/// Accumulates the provided signed samples in the metric.
///
/// This is required so that the platform-specific code can provide us with
Expand Down
2 changes: 1 addition & 1 deletion glean-core/src/traits/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{ErrorType, TestGetValue};
///
/// When changing this trait, make sure all the operations are
/// implemented in the related type in `../metrics/`.
pub trait Datetime: TestGetValue<crate::metrics::Datetime> {
pub trait Datetime: TestGetValue<Output = crate::metrics::Datetime> {
/// Sets the metric to a date/time which including the timezone offset.
///
/// # Arguments
Expand Down
2 changes: 1 addition & 1 deletion glean-core/src/traits/dual_labeled_counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::collections::HashMap;
///
/// When changing this trait, make sure all the operations are
/// implemented in the related type in `../metrics/`.
pub trait DualLabeledCounter: TestGetValue<HashMap<String, HashMap<String, i32>>> {
pub trait DualLabeledCounter: TestGetValue<Output = HashMap<String, HashMap<String, i32>>> {
/// Gets a specific counter for a given key/category pair.
///
/// If a set of acceptable keys or categorires were specified in the `metrics.yaml` file,
Expand Down
2 changes: 1 addition & 1 deletion glean-core/src/traits/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl TryFrom<&str> for NoExtraKeys {
///
/// When changing this trait, make sure all the operations are
/// implemented in the related type in `../metrics/`.
pub trait Event: TestGetValue<Vec<RecordedEvent>> {
pub trait Event: TestGetValue<Output = Vec<RecordedEvent>> {
/// The type of the allowed extra keys for this event.
type Extra: ExtraKeys;

Expand Down
2 changes: 1 addition & 1 deletion glean-core/src/traits/memory_distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{ErrorType, TestGetValue};
///
/// When changing this trait, make sure all the operations are
/// implemented in the related type in `../metrics/`.
pub trait MemoryDistribution: TestGetValue<DistributionData> {
pub trait MemoryDistribution: TestGetValue<Output = DistributionData> {
/// Accumulates the provided sample in the metric.
///
/// # Arguments
Expand Down
2 changes: 1 addition & 1 deletion glean-core/src/traits/numerator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{ErrorType, TestGetValue};
// When changing this trait, ensure all operations are implemented in the
// related type in `../metrics`. (Except test_get_num_errors)
/// A description for the `NumeratorMetric` subtype of the [`RateMetric`](crate::metrics::RateMetric) type.
pub trait Numerator: TestGetValue<Rate> {
pub trait Numerator: TestGetValue<Output = Rate> {
/// Increases the numerator by `amount`.
///
/// # Arguments
Expand Down
2 changes: 1 addition & 1 deletion glean-core/src/traits/quantity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{ErrorType, TestGetValue};
///
/// When changing this trait, make sure all the operations are
/// implemented in the related type in `../metrics/`.
pub trait Quantity: TestGetValue<i64> {
pub trait Quantity: TestGetValue<Output = i64> {
/// Sets the value. Must be non-negative.
///
/// # Arguments
Expand Down
2 changes: 1 addition & 1 deletion glean-core/src/traits/rate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{ErrorType, TestGetValue};
// When changing this trait, ensure all operations are implemented in the
// related type in `../metrics`. (Except test_get_num_errors)
/// A description for the [`RateMetric`](crate::metrics::RateMetric) type.
pub trait Rate: TestGetValue<crate::Rate> {
pub trait Rate: TestGetValue<Output = crate::Rate> {
/// Increases the numerator by `amount`.
///
/// # Arguments
Expand Down
2 changes: 1 addition & 1 deletion glean-core/src/traits/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{ErrorType, TestGetValue};
///
/// When changing this trait, make sure all the operations are
/// implemented in the related type in `../metrics/`.
pub trait String: TestGetValue<std::string::String> {
pub trait String: TestGetValue<Output = std::string::String> {
/// Sets to the specified value.
///
/// # Arguments
Expand Down
2 changes: 1 addition & 1 deletion glean-core/src/traits/string_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{ErrorType, TestGetValue};
///
/// When changing this trait, make sure all the operations are
/// implemented in the related type in `../metrics/`.
pub trait StringList: TestGetValue<Vec<String>> {
pub trait StringList: TestGetValue<Output = Vec<String>> {
/// Adds a new string to the list.
///
/// # Arguments
Expand Down
2 changes: 1 addition & 1 deletion glean-core/src/traits/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{ErrorType, TestGetValue};
///
/// When changing this trait, make sure all the operations are
/// implemented in the related type in `../metrics/`.
pub trait Text: TestGetValue<String> {
pub trait Text: TestGetValue<Output = String> {
/// Sets to the specified value.
///
/// # Arguments
Expand Down
Loading