Skip to content

Commit ea3b6fa

Browse files
committed
Add missing rustdocs for Windows code
1 parent 82ec5e9 commit ea3b6fa

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/runtime-core/src/loader.rs

+3
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,17 @@ unsafe impl Sync for CodeMemory {}
133133

134134
#[cfg(not(unix))]
135135
impl CodeMemory {
136+
/// Creates a new code memory with the given size.
136137
pub fn new(_size: usize) -> CodeMemory {
137138
unimplemented!("CodeMemory::new");
138139
}
139140

141+
/// Makes this code memory executable.
140142
pub fn make_executable(&self) {
141143
unimplemented!("CodeMemory::make_executable");
142144
}
143145

146+
/// Makes this code memory writable.
144147
pub fn make_writable(&self) {
145148
unimplemented!("CodeMemory::make_writable");
146149
}

lib/runtime-core/src/sys/windows/memory.rs

+17
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use winapi::um::winnt::{
1212
unsafe impl Send for Memory {}
1313
unsafe impl Sync for Memory {}
1414

15+
/// Data for a sized and protected region of memory.
1516
#[derive(Debug)]
1617
pub struct Memory {
1718
ptr: *mut u8,
@@ -20,6 +21,7 @@ pub struct Memory {
2021
}
2122

2223
impl Memory {
24+
/// Create a new memory from the given path value and protection.
2325
pub fn with_size_protect(size: usize, protection: Protect) -> Result<Self, String> {
2426
if size == 0 {
2527
return Ok(Self {
@@ -52,6 +54,7 @@ impl Memory {
5254
}
5355
}
5456

57+
/// Create a new memory with the given size.
5558
pub fn with_size(size: usize) -> Result<Self, MemoryCreationError> {
5659
if size == 0 {
5760
return Ok(Self {
@@ -79,6 +82,7 @@ impl Memory {
7982
}
8083
}
8184

85+
/// Protect this memory with the given range bounds and protection.
8286
pub unsafe fn protect(
8387
&mut self,
8488
range: impl RangeBounds<usize>,
@@ -120,6 +124,7 @@ impl Memory {
120124
}
121125
}
122126

127+
/// Split this memory into multiple memories by the given offset.
123128
pub fn split_at(mut self, offset: usize) -> (Memory, Memory) {
124129
let page_size = page_size::get();
125130
if offset % page_size == 0 {
@@ -140,22 +145,27 @@ impl Memory {
140145
}
141146
}
142147

148+
/// Gets the size of this memory.
143149
pub fn size(&self) -> usize {
144150
self.size
145151
}
146152

153+
/// Gets a slice for this memory.
147154
pub unsafe fn as_slice(&self) -> &[u8] {
148155
slice::from_raw_parts(self.ptr, self.size)
149156
}
150157

158+
/// Gets a mutable slice for this memory.
151159
pub unsafe fn as_slice_mut(&mut self) -> &mut [u8] {
152160
slice::from_raw_parts_mut(self.ptr, self.size)
153161
}
154162

163+
/// Gets the protect kind of this memory.
155164
pub fn protection(&self) -> Protect {
156165
self.protection
157166
}
158167

168+
/// Gets mutable pointer to the memory.
159169
pub fn as_ptr(&self) -> *mut u8 {
160170
self.ptr
161171
}
@@ -192,12 +202,17 @@ impl Clone for Memory {
192202
}
193203
}
194204

205+
/// Kinds of memory protection.
195206
#[derive(Serialize, Deserialize, Debug, Copy, Clone, PartialEq, Eq)]
196207
#[allow(dead_code)]
197208
pub enum Protect {
209+
/// Read/write/exec allowed.
198210
None,
211+
/// Read only.
199212
Read,
213+
/// Read/write only.
200214
ReadWrite,
215+
/// Read/exec only.
201216
ReadExec,
202217
}
203218

@@ -211,13 +226,15 @@ impl Protect {
211226
}
212227
}
213228

229+
/// Returns true if this memory is readable.
214230
pub fn is_readable(self) -> bool {
215231
match self {
216232
Protect::Read | Protect::ReadWrite | Protect::ReadExec => true,
217233
_ => false,
218234
}
219235
}
220236

237+
/// Returns true if this memory is writable.
221238
pub fn is_writable(self) -> bool {
222239
match self {
223240
Protect::ReadWrite => true,

0 commit comments

Comments
 (0)