-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(setup_states): new yaml reader, new read_config_state and types …
…adjusts for generalization
- Loading branch information
Showing
14 changed files
with
738 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Rust | ||
name: Rust build & tests | ||
|
||
on: [push] | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ zeroize = "1.7.0" | |
serde_json = "1.0.108" | ||
serde_derive = "1.0.193" | ||
anyhow = "1.0.75" | ||
serde_yaml = "0.9.30" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
use crate::config::Config; | ||
use mfm_machine::state::Label; | ||
use serde_derive::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] | ||
#[serde(rename_all = "snake_case")] | ||
pub enum ConfigSource { | ||
TomlFile(String), | ||
YamlFile(String), | ||
} | ||
pub const CONFIG_SOURCE_CTX: Label = Label("config_source_ctx"); | ||
|
||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] | ||
pub struct ReadConfig { | ||
pub struct ConfigCtx { | ||
pub config_source: ConfigSource, | ||
pub config: Config, | ||
} | ||
pub const READ_CONFIG: &str = "read_config"; | ||
pub const CONFIG_CTX: Label = Label("config_ctx"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,20 @@ | ||
use std::{fs::File, io::Read}; | ||
|
||
pub mod config; | ||
pub mod contexts; | ||
pub mod hidden; | ||
pub mod operations; | ||
pub mod password; | ||
pub mod states; | ||
pub mod tasks; | ||
|
||
use anyhow::Error; | ||
use serde::de::DeserializeOwned; | ||
|
||
fn read_yaml<T: DeserializeOwned>(path: String) -> Result<T, Error> { | ||
let mut file = File::open(path)?; | ||
let mut contents = String::new(); | ||
file.read_to_string(&mut contents)?; | ||
|
||
let instance: T = serde_yaml::from_str(&contents)?; | ||
Ok(instance) | ||
} |
File renamed without changes.
Oops, something went wrong.