sel4_driver_interfaces/
rtc.rs
1use core::cell::RefCell;
8use core::ops::Deref;
9
10use lock_api::{Mutex, RawMutex};
11
12use crate::{WrappedMutex, WrappedRefCell, WrappedRefCellError};
13
14pub use rtcc::{DateTime, DateTimeAccess, Datelike, NaiveDate, NaiveDateTime, NaiveTime, Timelike};
15
16impl<T: Deref<Target = RefCell<U>>, U: DateTimeAccess> DateTimeAccess for &WrappedRefCell<T> {
17 type Error = WrappedRefCellError<U::Error>;
18
19 fn datetime(&mut self) -> Result<NaiveDateTime, Self::Error> {
20 self.with_mut(|this| this.datetime())
21 }
22
23 fn set_datetime(&mut self, datetime: &NaiveDateTime) -> Result<(), Self::Error> {
24 self.with_mut(|this| this.set_datetime(datetime))
25 }
26}
27
28impl<R: RawMutex, T: Deref<Target = Mutex<R, U>>, U: DateTimeAccess> DateTimeAccess
29 for &WrappedMutex<T>
30{
31 type Error = U::Error;
32
33 fn datetime(&mut self) -> Result<NaiveDateTime, Self::Error> {
34 self.with_mut(|this| this.datetime())
35 }
36
37 fn set_datetime(&mut self, datetime: &NaiveDateTime) -> Result<(), Self::Error> {
38 self.with_mut(|this| this.set_datetime(datetime))
39 }
40}