glean_core/traits/
datetime.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
5#![allow(clippy::too_many_arguments)]
6
7use crate::{ErrorType, TestGetValue};
8
9/// A description for the [`DatetimeMetric`](crate::metrics::DatetimeMetric) type.
10///
11/// When changing this trait, make sure all the operations are
12/// implemented in the related type in `../metrics/`.
13pub trait Datetime: TestGetValue<Output = crate::metrics::Datetime> {
14    /// Sets the metric to a date/time which including the timezone offset.
15    ///
16    /// # Arguments
17    ///
18    /// * `value` - Some [`Datetime`](crate::metrics::Datetime), with offset, to
19    ///             set the metric to. If [`None`], the current local time is
20    ///             used.
21    fn set(&self, value: Option<crate::metrics::Datetime>);
22
23    /// **Exported for test purposes.**
24    ///
25    /// Gets the number of recorded errors for the given metric and error type.
26    ///
27    /// # Arguments
28    ///
29    /// * `error` - The type of error
30    ///
31    /// # Returns
32    ///
33    /// The number of errors reported.
34    fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32;
35}