Seal CommandExt trait

This is technically a breaking change, but we follow the standard
library's decision that sealing CommandExt is fine.
bfd1ccfb27
This commit is contained in:
Taiki Endo 2022-12-30 13:58:02 +09:00
parent 7980b4696a
commit f76d325959
3 changed files with 14 additions and 2 deletions

View File

@ -82,6 +82,10 @@ pub mod unix;
#[cfg(windows)]
pub mod windows;
mod sealed {
pub trait Sealed {}
}
/// An event delivered every time the SIGCHLD signal occurs.
static SIGCHLD: Event = Event::new();

View File

@ -7,7 +7,10 @@ use std::os::unix::process::CommandExt as _;
use crate::Command;
/// Unix-specific extensions to the [`Command`] builder.
pub trait CommandExt {
///
/// This trait is sealed: it cannot be implemented outside `async-process`.
/// This is so that future additional methods are not breaking changes.
pub trait CommandExt: crate::sealed::Sealed {
/// Sets the child process's user ID. This translates to a
/// `setuid` call in the child process. Failure in the `setuid`
/// call will cause the spawn to fail.
@ -88,6 +91,7 @@ pub trait CommandExt {
S: AsRef<OsStr>;
}
impl crate::sealed::Sealed for Command {}
impl CommandExt for Command {
fn uid(&mut self, id: u32) -> &mut Command {
self.inner.uid(id);

View File

@ -6,7 +6,10 @@ use std::os::windows::process::CommandExt as _;
use crate::{Child, Command};
/// Windows-specific extensions to the [`Command`] builder.
pub trait CommandExt {
///
/// This trait is sealed: it cannot be implemented outside `async-process`.
/// This is so that future additional methods are not breaking changes.
pub trait CommandExt: crate::sealed::Sealed {
/// Sets the [process creation flags][1] to be passed to `CreateProcess`.
///
/// These will always be ORed with `CREATE_UNICODE_ENVIRONMENT`.
@ -15,6 +18,7 @@ pub trait CommandExt {
fn creation_flags(&mut self, flags: u32) -> &mut Command;
}
impl crate::sealed::Sealed for Command {}
impl CommandExt for Command {
fn creation_flags(&mut self, flags: u32) -> &mut Command {
self.inner.creation_flags(flags);