use serde::Deserialize; #[derive(Clone, Debug, Deserialize, Default)] pub struct Profile { pub name: String, pub key: String, } impl Profile { pub fn load_fs_content(str_path: String) -> String { let file_path = std::path::Path::new(&str_path); if ! std::path::Path::new(&file_path).exists() { eprintln!("Path {} not found", &str_path); return String::from(""); } std::fs::read_to_string(file_path).unwrap_or_else(|e| { eprintln!("{}", e); String::from("") }) } pub fn to_yaml(content: String) -> serde_yaml::Value { match serde_yaml::from_str(&content) { Ok(profile) => { // println!("Profile Loaded successfully"); profile } Err(_e) => { // println!("Profile error: {}", e); "".into() } } } }