Refactor: move load_vm_config to associated function on VmConfig.
Bug: 171277638
Test: m virtmanager
Change-Id: I94ff72693dc9e1b654827591bd233e95bd35743e
diff --git a/virtmanager/src/config.rs b/virtmanager/src/config.rs
index c0d23f0..d8cb06f 100644
--- a/virtmanager/src/config.rs
+++ b/virtmanager/src/config.rs
@@ -49,6 +49,13 @@
}
Ok(())
}
+
+ /// Load the configuration for a VM from the given JSON file.
+ pub fn load(path: &str) -> Result<VmConfig, Error> {
+ let file = File::open(path).with_context(|| format!("Failed to open {}", path))?;
+ let buffered = BufReader::new(file);
+ Ok(serde_json::from_reader(buffered)?)
+ }
}
/// A disk image to be made available to the VM.
@@ -59,10 +66,3 @@
/// Whether this disk should be writable by the VM.
pub writable: bool,
}
-
-/// Load the configuration for the VM with the given ID from a JSON file.
-pub fn load_vm_config(path: &str) -> Result<VmConfig, Error> {
- let file = File::open(path).with_context(|| format!("Failed to open {}", path))?;
- let buffered = BufReader::new(file);
- Ok(serde_json::from_reader(buffered)?)
-}