@@ -4,6 +4,7 @@ use core::arch::asm;
4
4
use core:: fmt;
5
5
use core:: marker:: PhantomData ;
6
6
7
+ use crate :: sealed:: Sealed ;
7
8
pub use crate :: structures:: port:: { PortRead , PortWrite } ;
8
9
9
10
impl PortRead for u8 {
@@ -66,43 +67,43 @@ impl PortWrite for u32 {
66
67
}
67
68
}
68
69
69
- mod sealed {
70
- pub trait Access {
71
- const DEBUG_NAME : & ' static str ;
72
- }
73
- }
70
+ /// A marker trait for access types which allow accessing port values.
71
+ pub trait PortAccess : Sealed { }
74
72
75
73
/// A marker trait for access types which allow reading port values.
76
- pub trait PortReadAccess : sealed :: Access { }
74
+ pub trait PortReadAccess : PortAccess { }
77
75
78
76
/// A marker trait for access types which allow writing port values.
79
- pub trait PortWriteAccess : sealed :: Access { }
77
+ pub trait PortWriteAccess : PortAccess { }
80
78
81
79
/// An access marker type indicating that a port is only allowed to read values.
82
80
#[ derive( Debug ) ]
83
81
pub struct ReadOnlyAccess ( ( ) ) ;
84
82
85
- impl sealed :: Access for ReadOnlyAccess {
86
- const DEBUG_NAME : & ' static str = "ReadOnly" ;
83
+ impl Sealed for ReadOnlyAccess {
84
+ const DEBUG_STR : & ' static str = "ReadOnly" ;
87
85
}
86
+ impl PortAccess for ReadOnlyAccess { }
88
87
impl PortReadAccess for ReadOnlyAccess { }
89
88
90
89
/// An access marker type indicating that a port is only allowed to write values.
91
90
#[ derive( Debug ) ]
92
91
pub struct WriteOnlyAccess ( ( ) ) ;
93
92
94
- impl sealed :: Access for WriteOnlyAccess {
95
- const DEBUG_NAME : & ' static str = "WriteOnly" ;
93
+ impl Sealed for WriteOnlyAccess {
94
+ const DEBUG_STR : & ' static str = "WriteOnly" ;
96
95
}
96
+ impl PortAccess for WriteOnlyAccess { }
97
97
impl PortWriteAccess for WriteOnlyAccess { }
98
98
99
99
/// An access marker type indicating that a port is allowed to read or write values.
100
100
#[ derive( Debug ) ]
101
101
pub struct ReadWriteAccess ( ( ) ) ;
102
102
103
- impl sealed :: Access for ReadWriteAccess {
104
- const DEBUG_NAME : & ' static str = "ReadWrite" ;
103
+ impl Sealed for ReadWriteAccess {
104
+ const DEBUG_STR : & ' static str = "ReadWrite" ;
105
105
}
106
+ impl PortAccess for ReadWriteAccess { }
106
107
impl PortReadAccess for ReadWriteAccess { }
107
108
impl PortWriteAccess for ReadWriteAccess { }
108
109
@@ -165,12 +166,12 @@ impl<T: PortWrite, A: PortWriteAccess> PortGeneric<T, A> {
165
166
}
166
167
}
167
168
168
- impl < T , A : sealed :: Access > fmt:: Debug for PortGeneric < T , A > {
169
+ impl < T , A : PortAccess > fmt:: Debug for PortGeneric < T , A > {
169
170
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
170
171
f. debug_struct ( "PortGeneric" )
171
172
. field ( "port" , & self . port )
172
173
. field ( "size" , & core:: mem:: size_of :: < T > ( ) )
173
- . field ( "access" , & format_args ! ( "{}" , A :: DEBUG_NAME ) )
174
+ . field ( "access" , & format_args ! ( "{}" , A :: DEBUG_STR ) )
174
175
. finish ( )
175
176
}
176
177
}
0 commit comments