added get_instance_config in rootConfig
This commit is contained in:
@@ -1,9 +1,8 @@
|
|||||||
use clap::builder::Str;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{
|
use std::{
|
||||||
error::Error,
|
error::Error,
|
||||||
fs::{self, read_to_string},
|
fs::{self, read_to_string},
|
||||||
io::{self, Write},
|
io::Write,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -48,13 +47,15 @@ impl RootConfig {
|
|||||||
|
|
||||||
pub fn load_instance_by_id(&self, id: &str) -> Result<ModdedInstance, Box<dyn Error>> {
|
pub fn load_instance_by_id(&self, id: &str) -> Result<ModdedInstance, Box<dyn Error>> {
|
||||||
let conf = self
|
let conf = self
|
||||||
.instances
|
.get_instance_config(id)
|
||||||
.iter()
|
|
||||||
.find(|e| e.id == id)
|
|
||||||
.ok_or("ID not found in root config")?;
|
.ok_or("ID not found in root config")?;
|
||||||
|
|
||||||
ModdedInstance::load_from_file(&conf.path)
|
ModdedInstance::load_from_file(&conf.path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_instance_config(&self, id: &str) -> Option<&InstancePointer> {
|
||||||
|
self.instances.iter().find(|e| e.id == id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Available game
|
/// Available game
|
||||||
|
|||||||
Reference in New Issue
Block a user