Skip to main content

a3s_box_runtime/network/
mod.rs

1//! Network management for container-to-container communication.
2//!
3//! Provides `NetworkStore` for persisting network state and
4//! platform-specific network backend managers for bridge networking:
5//! - Linux: `PasstManager` (passt Unix stream socket)
6//! - macOS: `NetProxyManager` (pure-Rust vfkit server, no external binary)
7
8#[cfg(any(target_os = "linux", test))]
9mod passt;
10mod store;
11
12#[cfg(target_os = "macos")]
13pub use a3s_box_netproxy::NetProxyManager;
14#[cfg(any(target_os = "linux", test))]
15pub use passt::{terminate_passt, PasstManager};
16pub use store::NetworkStore;
17
18/// Platform-agnostic handle to a running network backend process or thread.
19pub trait NetworkBackend: Send + Sync {
20    /// Path to the Unix socket used to communicate with this backend.
21    fn socket_path(&self) -> &std::path::Path;
22    /// Stop the backend and clean up the socket.
23    fn stop(&mut self);
24}
25
26#[cfg(target_os = "macos")]
27impl NetworkBackend for NetProxyManager {
28    fn socket_path(&self) -> &std::path::Path {
29        self.socket_path()
30    }
31
32    fn stop(&mut self) {
33        self.stop();
34    }
35}