1use core::fmt::Debug;
4use core::hash::Hash;
5
6#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
10pub struct ReadOnly {}
11
12#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
16pub struct WriteOnly {}
17
18#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
22pub struct ReadWrite {}
23
24pub trait Access:
28 Debug + Default + Copy + Eq + Ord + Hash + Sized + Send + Sync + 'static + private::Sealed
29{
30}
31
32#[diagnostic::on_unimplemented(
36 message = "cannot read from a write-only register",
37 label = "method cannot be called on write-only registers",
38 note = "the register is write only because it was annotated with the attribute
39 `#[reg(WO)]` in the register-map definition"
40)]
41pub trait Readable: Access {}
42
43#[diagnostic::on_unimplemented(
47 message = "cannot write to a read-only register",
48 label = "method cannot be called on read-only registers",
49 note = "the register is read only because it was annotated with the attribute
50 `#[reg(RO)]` in the register-map definition"
51)]
52pub trait Writable: Access {}
53
54impl Access for ReadOnly {}
55impl Access for WriteOnly {}
56impl Access for ReadWrite {}
57impl Readable for ReadOnly {}
58impl Readable for ReadWrite {}
59impl Writable for WriteOnly {}
60impl Writable for ReadWrite {}
61
62mod private {
63 pub trait Sealed {}
64 impl Sealed for super::ReadOnly {}
65 impl Sealed for super::WriteOnly {}
66 impl Sealed for super::ReadWrite {}
67}