Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add links to safety docs in map methods #121

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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