diff options
Diffstat (limited to 'src/sandbox/remote.rs')
| -rw-r--r-- | src/sandbox/remote.rs | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/sandbox/remote.rs b/src/sandbox/remote.rs index c648843..6d369e2 100644 --- a/src/sandbox/remote.rs +++ b/src/sandbox/remote.rs @@ -9,13 +9,34 @@ use crate::error::{Error, Result}; use crate::sandbox::wire::{self, Frame}; use crate::sandbox::{Exit, Sandbox, SandboxBackend, SandboxInfo, SandboxSpec}; -pub struct RemoteBackend { - cfg: Config, - token: String, - addr: String, - queue: Receiver<std::net::TcpStream>, +/// 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 remote_backend { + use super::*; + // `pub` fields inside a private module are not nameable from + // outside; they stay readable by the impls below. + + pub struct RemoteBackend { + pub cfg: Config, + pub token: String, + pub addr: String, + pub queue: Receiver<std::net::TcpStream>, + } } +/// The remote backend, built by `backend_for`. A fixture test builds one to drive the agent protocol. +/// +/// `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 remote_backend::RemoteBackend; + +#[cfg(not(feature = "test-support"))] +pub(crate) use remote_backend::RemoteBackend; + impl RemoteBackend { pub fn bind(cfg: &Config, addr: &str, token: &str) -> Result<Self> { let bound = super::bound_listener(addr, token)?; |
