Skip to content

Seal extension traits #20

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

Merged
merged 1 commit into from
Aug 17, 2023
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
20 changes: 16 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1507,9 +1507,20 @@ impl windows::OpenOptionsExt for OpenOptions {
}
}

mod __private {
#[doc(hidden)]
pub trait Sealed {}

impl Sealed for super::OpenOptions {}
impl Sealed for super::File {}
impl Sealed for super::DirBuilder {}
impl Sealed for super::DirEntry {}
}

/// Unix-specific extensions.
#[cfg(unix)]
pub mod unix {
use super::__private::Sealed;
use super::*;

#[doc(no_inline)]
Expand All @@ -1533,7 +1544,7 @@ pub mod unix {
}

/// Unix-specific extensions to [`DirBuilder`].
pub trait DirBuilderExt {
pub trait DirBuilderExt: Sealed {
/// Sets the mode to create new directories with.
///
/// This option defaults to `0o777`.
Expand All @@ -1550,7 +1561,7 @@ pub mod unix {
}

/// Unix-specific extension methods for [`DirEntry`].
pub trait DirEntryExt {
pub trait DirEntryExt: Sealed {
/// Returns the underlying `d_ino` field in the contained `dirent` structure.
///
/// # Examples
Expand All @@ -1571,7 +1582,7 @@ pub mod unix {
}

/// Unix-specific extensions to [`OpenOptions`].
pub trait OpenOptionsExt {
pub trait OpenOptionsExt: Sealed {
/// Sets the mode bits that a new file will be created with.
///
/// If a new file is created as part of an [`OpenOptions::open()`] call then this
Expand Down Expand Up @@ -1622,6 +1633,7 @@ pub mod unix {
/// Windows-specific extensions.
#[cfg(windows)]
pub mod windows {
use super::__private::Sealed;
use super::*;

#[doc(no_inline)]
Expand Down Expand Up @@ -1662,7 +1674,7 @@ pub mod windows {
}

/// Windows-specific extensions to [`OpenOptions`].
pub trait OpenOptionsExt {
pub trait OpenOptionsExt: Sealed {
/// Overrides the `dwDesiredAccess` argument to the call to [`CreateFile`]
/// with the specified value.
///
Expand Down