1// Copyright 2022 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
45use crate::TestEnv;
6use fidl_fuchsia_thermal as fthermal;
78/// Convenience type for interacting with the Power Manager's thermal client service.
9pub struct ThermalClient {
10 watcher_proxy: fthermal::ClientStateWatcherProxy,
11}
1213impl ThermalClient {
14pub fn new(test_env: &TestEnv, client_type: &str) -> Self {
15let connector = test_env.connect_to_protocol::<fthermal::ClientStateConnectorMarker>();
16let (watcher_proxy, watcher_remote) =
17 fidl::endpoints::create_proxy::<fthermal::ClientStateWatcherMarker>();
18 connector.connect(client_type, watcher_remote).expect("Failed to connect thermal client");
19Self { watcher_proxy }
20 }
2122pub async fn get_thermal_state(&self) -> Result<u64, anyhow::Error> {
23self.watcher_proxy.watch().await.map_err(|e| e.into())
24 }
25}