starnix_core/task/kernel_stats.rs
1// Copyright 2023 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.
4
5use fuchsia_component::client::connect_to_protocol_sync;
6use std::sync::OnceLock;
7
8#[derive(Default)]
9pub struct KernelStats(OnceLock<fidl_fuchsia_kernel::StatsSynchronousProxy>);
10
11impl KernelStats {
12 pub fn get(&self) -> &fidl_fuchsia_kernel::StatsSynchronousProxy {
13 self.0.get_or_init(|| {
14 connect_to_protocol_sync::<fidl_fuchsia_kernel::StatsMarker>()
15 .expect("Failed to connect to fuchsia.kernel.Stats.")
16 })
17 }
18}