blob: 16191d5789ff61e3a3796d53a4a19aa08f7d6fe3 [file]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
anyhow::Error,
fidl_fuchsia_settings::{PrivacyProxy, PrivacySettings},
};
pub async fn command(
proxy: PrivacyProxy,
user_data_sharing_consent: Option<bool>,
) -> Result<String, Error> {
if let Some(user_data_sharing_consent_value) = user_data_sharing_consent {
let mut settings = PrivacySettings::empty();
settings.user_data_sharing_consent = Some(user_data_sharing_consent_value);
let mutate_result = proxy.set(settings).await?;
match mutate_result {
Ok(_) => Ok(format!(
"Successfully set user_data_sharing_consent to {}",
user_data_sharing_consent_value
)),
Err(err) => Ok(format!("{:?}", err)),
}
} else {
let setting_value = proxy.watch().await?;
Ok(format!("{:?}", setting_value))
}
}