summaryrefslogtreecommitdiffstats
path: root/src/sandbox/loopback.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/sandbox/loopback.rs')
-rw-r--r--src/sandbox/loopback.rs25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/sandbox/loopback.rs b/src/sandbox/loopback.rs
index 7847fdc..9629206 100644
--- a/src/sandbox/loopback.rs
+++ b/src/sandbox/loopback.rs
@@ -7,10 +7,31 @@ use crate::config::Config;
use crate::error::{Error, Result};
use crate::sandbox::{Cmd, Exit, Sandbox, SandboxBackend, SandboxInfo, SandboxSpec};
-pub struct LoopbackBackend {
- cfg: Config,
+/// The real definition. The module is private, so this `pub`
+/// is not a nameable path from outside; the alias below is the
+/// only way to reach it, and the alias is what carries the
+/// feature-conditional visibility.
+mod loopback_backend {
+ use super::*;
+ // `pub` fields inside a private module are not nameable from
+ // outside; they stay readable by the impls below.
+
+ pub struct LoopbackBackend {
+ pub cfg: Config,
+ }
}
+/// The default backend, built by `backend_for`. A failure test builds one to inject a fault.
+///
+/// `pub` only under `test-support`. Production reaches the type
+/// through its own module and never names it from outside; the
+/// outside reader that needs the name is a test.
+#[cfg(feature = "test-support")]
+pub use loopback_backend::LoopbackBackend;
+
+#[cfg(not(feature = "test-support"))]
+pub(crate) use loopback_backend::LoopbackBackend;
+
impl LoopbackBackend {
pub fn new(cfg: &Config) -> Self {
Self { cfg: cfg.clone() }