#![forbid(unsafe_code)]
mod sandbox;
pub use sandbox::{MountConfig, PortForwardHandle, Sandbox, VmConfigBuilder};
pub use shuru_proto::{
frame, ExecRequest, ForwardRequest, ForwardResponse, MountRequest, MountResponse, PortMapping,
ReadFileRequest, WriteFileRequest, WriteFileResponse, VSOCK_PORT, VSOCK_PORT_FORWARD,
};
#[cfg(target_os = "macos")]
pub use shuru_darwin::VirtualMachine;
#[cfg(target_os = "macos")]
pub use shuru_darwin::VmState;
#[cfg(target_os = "macos")]
pub use shuru_darwin::VzError;
#[cfg(target_os = "linux")]
pub use shuru_linux::VirtualMachine;
#[cfg(target_os = "linux")]
pub use shuru_linux::VmState;
#[cfg(target_os = "linux")]
pub use shuru_linux::VzError;
pub fn validate_checkpoint_name(name: &str) -> Result<(), String> {
if name.is_empty() {
return Err("checkpoint name cannot be empty".into());
}
if name.contains('/') || name.contains('\\') || name.contains('\0') || name.contains("..") {
return Err(format!("invalid checkpoint name: '{}'", name));
}
Ok(())
}
pub fn default_data_dir() -> String {
let home = std::env::var("HOME").unwrap_or_else(|_| "/tmp".to_string());
format!("{}/.local/share/shuru", home)
}