[UniFFI] Update docs for boolean, timespan and ping

This commit is contained in:
Jan-Erik Rediger 2021-12-14 12:51:23 +01:00 коммит произвёл Jan-Erik Rediger
Родитель 076947f57d
Коммит 86af70b64a
3 изменённых файлов: 17 добавлений и 16 удалений

Просмотреть файл

@ -58,6 +58,7 @@ impl BooleanMetric {
///
/// * `glean` - the Glean instance this metric belongs to.
/// * `value` - the value to set.
#[doc(hidden)]
pub fn set_sync(&self, glean: &Glean, value: bool) {
if !self.should_record(glean) {
return;
@ -83,6 +84,7 @@ impl BooleanMetric {
/// Gets the currently stored value as a boolean.
///
/// This doesn't clear the stored value.
#[doc(hidden)]
pub fn get_value(&self, glean: &Glean, ping_name: Option<&str>) -> Option<bool> {
let queried_ping_name = ping_name.unwrap_or_else(|| &self.meta().send_in_pings[0]);

Просмотреть файл

@ -87,9 +87,14 @@ impl PingType {
/// Submits the ping for eventual uploading.
///
/// The ping content is assembled as soon as possible, but upload is not
/// guaranteed to happen immediately, as that depends on the upload policies.
///
/// If the ping currently contains no content, it will not be sent,
/// unless it is configured to be sent if empty.
///
/// # Arguments
///
/// * `glean` - the Glean instance to use to send the ping.
/// * `reason` - the reason the ping was triggered. Included in the
/// `ping_info.reason` part of the payload.
pub fn submit(&self, reason: Option<String>) {
@ -105,20 +110,10 @@ impl PingType {
/// Collects and submits a ping for eventual uploading.
///
/// The ping content is assembled as soon as possible, but upload is not
/// guaranteed to happen immediately, as that depends on the upload policies.
///
/// If the ping currently contains no content, it will not be sent,
/// unless it is configured to be sent if empty.
///
/// # Arguments
///
/// * `ping` - The ping to submit
/// * `reason` - A reason code to include in the ping
///
/// # Returns
///
/// Whether the ping was succesfully assembled and queued.
#[doc(hidden)]
pub fn submit_sync(&self, glean: &Glean, reason: Option<&str>) -> bool {
if !glean.is_upload_enabled() {
log::info!("Glean disabled: not submitting any pings.");

Просмотреть файл

@ -62,7 +62,8 @@ impl TimespanMetric {
crate::launch_with_glean(move |glean| metric.set_start(glean, start_time));
}
/// Set start time.
/// Set start time synchronously.
#[doc(hidden)]
pub fn set_start(&self, glean: &Glean, start_time: u64) {
if !self.should_record(glean) {
return;
@ -97,7 +98,8 @@ impl TimespanMetric {
crate::launch_with_glean(move |glean| metric.set_stop(glean, stop_time));
}
/// Set stop time.
/// Set stop time synchronously.
#[doc(hidden)]
pub fn set_stop(&self, glean: &Glean, stop_time: u64) {
// Need to write in either case, so get the lock first.
let mut lock = self
@ -174,7 +176,7 @@ impl TimespanMetric {
crate::launch_with_glean(move |glean| metric.set_raw_sync(glean, elapsed));
}
/// Explicitly sets the timespan value.
/// Explicitly sets the timespan value in nanoseconds.
///
/// This API should only be used if your library or application requires
/// recording times in a way that can not make use of
@ -193,7 +195,8 @@ impl TimespanMetric {
self.set_raw(elapsed)
}
/// Set raw but sync
/// Explicitly sets the timespan value synchronously.
#[doc(hidden)]
pub fn set_raw_sync(&self, glean: &Glean, elapsed: Duration) {
if !self.meta.should_record() {
return;
@ -260,6 +263,7 @@ impl TimespanMetric {
}
/// Get the current value
#[doc(hidden)]
pub fn get_value<'a, S: Into<Option<&'a str>>>(
&self,
glean: &Glean,