Coverage Report

Created: 2026-06-08 06:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/spdm-rs/spdmlib/src/time/mod.rs
Line
Count
Source
1
// Copyright (c) 2022 Intel Corporation
2
//
3
// SPDX-License-Identifier: Apache-2.0 or MIT
4
5
mod time_callbacks;
6
7
pub use time_callbacks::SpdmTime;
8
9
use conquer_once::spin::OnceCell;
10
11
static TIME_INSTANCE: OnceCell<SpdmTime> = OnceCell::uninit();
12
13
static DEFAULT: SpdmTime = SpdmTime {
14
0
    sleep_cb: |_: usize| unimplemented!(),
15
};
16
17
0
pub fn register(context: SpdmTime) -> bool {
18
0
    TIME_INSTANCE.try_init_once(|| context).is_ok()
19
0
}
20
21
0
pub fn sleep(us: usize) {
22
0
    (TIME_INSTANCE
23
0
        .try_get_or_init(|| DEFAULT.clone())
24
0
        .ok()
25
0
        .unwrap()
26
0
        .sleep_cb)(us)
27
0
}