diff options
| author | aur-build <aur-build@localhost> | 2026-11-20 23:38:01 +0000 |
|---|---|---|
| committer | aur-build <aur-build@localhost> | 2026-11-20 23:38:01 +0000 |
| commit | c295510e2bb0ee61234536c832dad87a45977fc8 (patch) | |
| tree | d9e73e141da7eb2b09e553998a1435ad023cc0ac /src/sandbox/mod.rs | |
| parent | 92ecaabd7c62d029eba239e95cc8a7d2520fe4a9 (diff) | |
| download | aur-build-c295510e2bb0ee61234536c832dad87a45977fc8.tar.gz aur-build-c295510e2bb0ee61234536c832dad87a45977fc8.zip | |
sandbox: keep `Exit` out of the release build
`Exit` is the result of running a command in a sandbox. `pipeline` consumes it
through `Sandbox::run` — `.success()`, `.stderr` — without ever writing the name,
which is why the census called it dead outside `sandbox`.
The type now lives in a private `mod exit` and reaches the world through an
alias that is `pub` only under `test-support` and `pub(crate)` otherwise. A
`pub` definition inside a private module is not a nameable path from outside,
but it is visible enough to appear in a public trait signature, which is what
makes this possible where a plain `pub(crate) struct` is not.
Verified with an external crate: naming `aur_build::sandbox::Exit` in a release
build is `error[E0603]: struct Exit is private`; with `test-support` it compiles.
Diffstat (limited to 'src/sandbox/mod.rs')
| -rw-r--r-- | src/sandbox/mod.rs | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/sandbox/mod.rs b/src/sandbox/mod.rs index 3bd4b3b..6c90f7f 100644 --- a/src/sandbox/mod.rs +++ b/src/sandbox/mod.rs @@ -39,19 +39,26 @@ impl Cmd { } } -#[derive(Debug)] -pub struct Exit { - pub code: Option<i32>, - pub stdout: Vec<u8>, - pub stderr: Vec<u8>, -} +mod exit { + #[derive(Debug)] + pub struct Exit { + pub code: Option<i32>, + pub stdout: Vec<u8>, + pub stderr: Vec<u8>, + } -impl Exit { - pub fn success(&self) -> bool { - self.code == Some(0) + impl Exit { + pub fn success(&self) -> bool { + self.code == Some(0) + } } } +#[cfg(feature = "test-support")] +pub use exit::Exit; +#[cfg(not(feature = "test-support"))] +pub(crate) use exit::Exit; + #[derive(Debug, Clone)] pub struct SandboxSpec { pub profile: String, |
