| 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 |
|
| 7 |
use crate::ErrorType; |
| 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/`. |
| 13 |
pub trait 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 currently stored value as a Datetime. |
| 26 |
/// |
| 27 |
/// The precision of this value is truncated to the `time_unit` precision. |
| 28 |
/// |
| 29 |
/// This doesn't clear the stored value. |
| 30 |
/// |
| 31 |
/// # Arguments |
| 32 |
/// |
| 33 |
/// * `ping_name` - represents the optional name of the ping to retrieve the |
| 34 |
/// metric for. Defaults to the first value in `send_in_pings`. |
| 35 |
fn test_get_value<'a, S: Into<Option<&'a str>>>( |
| 36 |
&self, |
| 37 |
ping_name: S, |
| 38 |
) -> Option<crate::metrics::Datetime>; |
| 39 |
|
| 40 |
/// **Exported for test purposes.** |
| 41 |
/// |
| 42 |
/// Gets the number of recorded errors for the given metric and error type. |
| 43 |
/// |
| 44 |
/// # Arguments |
| 45 |
/// |
| 46 |
/// * `error` - The type of error |
| 47 |
/// |
| 48 |
/// # Returns |
| 49 |
/// |
| 50 |
/// The number of errors reported. |
| 51 |
fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32; |
| 52 |
} |