use serde::{Deserialize, Serialize}; use std::{ffi::OsString, process::Command}; pub use error::{Error, Result}; pub mod error; #[derive(Serialize, Deserialize, Clone)] pub struct Container { pub machine: OsString, pub class: OsString, pub service: OsString, pub os: OsString, pub version: OsString, pub addresses: OsString, } /// Uses Command to call to machinectl list -o json pub fn get_containers() -> Result> { Command::new("machinectl") .arg("list") .args(["-o", "json"]) .output() .map(|o| serde_json::from_slice(o.stdout.as_slice()))? .map_err(Error::from) } #[cfg(test)] mod tests { #[test] fn it_works() { let result = 2 + 2; assert_eq!(result, 4); } }