File tree 1 file changed +10
-6
lines changed
1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -8,11 +8,11 @@ use core::ops::{Deref, DerefMut};
8
8
/// This type is page-aligned and page-sized.
9
9
#[ derive( Copy , Clone ) ]
10
10
#[ repr( C , align( 4096 ) ) ]
11
- pub struct Page ( [ [ u64 ; 32 ] ; 16 ] ) ;
11
+ pub struct Page ( [ u8 ; Self :: SIZE ] ) ;
12
12
13
13
#[ cfg( feature = "const-default" ) ]
14
14
impl const_default:: ConstDefault for Page {
15
- const DEFAULT : Self = Self ( [ [ 0 ; 32 ] ; 16 ] ) ;
15
+ const DEFAULT : Self = Self :: zeroed ( ) ;
16
16
}
17
17
18
18
impl Default for Page {
@@ -67,13 +67,17 @@ impl BorrowMut<[u8]> for Page {
67
67
}
68
68
69
69
impl Page {
70
- /// Returns the size of the page in bytes
71
- pub const fn size ( ) -> usize {
72
- core:: mem:: size_of :: < Self > ( )
70
+ /// The page size on the platform
71
+ pub const SIZE : usize = 4096 ;
72
+
73
+ /// Creates a new page from its bytes
74
+ #[ inline]
75
+ pub const fn new ( value : [ u8 ; Self :: SIZE ] ) -> Self {
76
+ Self ( value)
73
77
}
74
78
75
79
/// Returns a Page full of zeroes
76
80
pub const fn zeroed ( ) -> Self {
77
- Self ( [ [ 0 ; 32 ] ; 16 ] )
81
+ Self ( [ 0 ; Self :: SIZE ] )
78
82
}
79
83
}
You can’t perform that action at this time.
0 commit comments