Skip to content

Commit

Permalink
Add links to safety docs in map methods (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Sep 6, 2024
1 parent f7c5083 commit 4996205
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,10 @@ impl MmapOptions {

/// Creates a read-only memory map backed by a file.
///
/// # Safety
///
/// See the [type-level][MmapOptions] docs for why this function is unsafe.
///
/// # Errors
///
/// This method returns an error when the underlying system call fails, which can happen for a
Expand Down Expand Up @@ -373,6 +377,10 @@ impl MmapOptions {

/// Creates a readable and executable memory map backed by a file.
///
/// # Safety
///
/// See the [type-level][MmapOptions] docs for why this function is unsafe.
///
/// # Errors
///
/// This method returns an error when the underlying system call fails, which can happen for a
Expand All @@ -386,6 +394,10 @@ impl MmapOptions {

/// Creates a writeable memory map backed by a file.
///
/// # Safety
///
/// See the [type-level][MmapOptions] docs for why this function is unsafe.
///
/// # Errors
///
/// This method returns an error when the underlying system call fails, which can happen for a
Expand Down Expand Up @@ -429,6 +441,10 @@ impl MmapOptions {
/// Data written to the memory map will not be visible by other processes,
/// and will not be carried through to the underlying file.
///
/// # Safety
///
/// See the [type-level][MmapOptions] docs for why this function is unsafe.
///
/// # Errors
///
/// This method returns an error when the underlying system call fails, which can happen for a
Expand Down Expand Up @@ -457,6 +473,10 @@ impl MmapOptions {

/// Creates a copy-on-write read-only memory map backed by a file.
///
/// # Safety
///
/// See the [type-level][MmapOptions] docs for why this function is unsafe.
///
/// # Errors
///
/// This method returns an error when the underlying system call fails, which can happen for a
Expand Down Expand Up @@ -596,6 +616,10 @@ impl Mmap {
///
/// This is equivalent to calling `MmapOptions::new().map(file)`.
///
/// # Safety
///
/// See the [type-level][Mmap] docs for why this function is unsafe.
///
/// # Errors
///
/// This method returns an error when the underlying system call fails, which can happen for a
Expand Down Expand Up @@ -789,6 +813,9 @@ impl fmt::Debug for Mmap {
///
/// This struct never hands out references to its interior, only raw pointers.
/// This can be helpful when creating shared memory maps between untrusted processes.
///
/// For the safety concerns that arise when converting these raw pointers to references,
/// see the [`Mmap`] safety documentation.
pub struct MmapRaw {
inner: MmapInner,
}
Expand Down Expand Up @@ -1058,6 +1085,10 @@ impl MmapMut {
///
/// This is equivalent to calling `MmapOptions::new().map_mut(file)`.
///
/// # Safety
///
/// See the [type-level][MmapMut] docs for why this function is unsafe.
///
/// # Errors
///
/// This method returns an error when the underlying system call fails, which can happen for a
Expand Down

0 comments on commit 4996205

Please sign in to comment.