emerald_kernel_user_link/clock.rs
1#[repr(C)]
2#[derive(Debug, Copy, Clone)]
3pub struct ClockTime {
4 pub seconds: u64,
5 pub nanoseconds: u32,
6}
7
8#[repr(C)]
9#[derive(Debug, Copy, Clone)]
10pub enum ClockType {
11 /// Real time clock, this follows the unix time
12 RealTime = 0,
13 /// Monotonic system time, this is based on the system time since boot
14 SystemTime = 1,
15}
16
17impl TryFrom<u64> for ClockType {
18 type Error = ();
19
20 fn try_from(value: u64) -> Result<Self, Self::Error> {
21 match value {
22 0 => Ok(ClockType::RealTime),
23 1 => Ok(ClockType::SystemTime),
24 _ => Err(()),
25 }
26 }
27}