arcbox_vmnet/lib.rs
1//! Safe Rust bindings for Apple's vmnet.framework.
2//!
3//! This crate exposes:
4//! - Low-level FFI declarations for `vmnet`, Core Foundation, GCD dispatch,
5//! XPC, and the Objective-C block ABI required by `vmnet_start_interface`.
6//! - A high-level [`Vmnet`] interface for creating shared (NAT), host-only,
7//! and bridged virtual network interfaces.
8//! - A [`VmnetRelay`] that bridges vmnet's blocking read/write API to a
9//! `socketpair` consumed by `VZFileHandleNetworkDeviceAttachment`.
10//!
11//! # Operating modes
12//!
13//! - **Shared (NAT)** — VMs share the host's network connection via NAT,
14//! with vmnet providing DHCP and DNS.
15//! - **Host-only** — Isolated network between VMs and host, optionally
16//! with per-interface isolation via UUID.
17//! - **Bridged** — VMs appear as separate L2 devices on a physical network.
18//!
19//! # Requirements
20//!
21//! - macOS 11.0 or later.
22//! - The `com.apple.vm.networking` entitlement, or root, is required to
23//! start a vmnet interface.
24//!
25//! # Feature flags
26//!
27//! - `vmnet` — Enable the proper Objective-C completion-handler ABI for
28//! `vmnet_start_interface`. Without it, the interface starts with a
29//! NULL handler and falls back to default packet-size / generated MAC.
30
31#![cfg(target_os = "macos")]
32
33pub mod error;
34pub mod ffi;
35mod interface;
36mod relay;
37
38pub use error::{Result, VmnetError};
39pub use interface::{Vmnet, VmnetConfig, VmnetInterfaceInfo, VmnetMode};
40pub use relay::VmnetRelay;