mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
Engine (#38)
- Avoid lifetime parameter for Source, Span. Use Rc instead. - Engine for simplified API Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
committed by
GitHub
parent
a751cd69e1
commit
d69b413c8e
18
src/value.rs
18
src/value.rs
@@ -165,6 +165,24 @@ impl Value {
|
||||
pub fn to_json_str(&self) -> Result<String> {
|
||||
Ok(serde_json::to_string_pretty(self)?)
|
||||
}
|
||||
|
||||
pub fn from_json_file(path: &String) -> Result<Value> {
|
||||
match std::fs::read_to_string(path) {
|
||||
Ok(c) => Self::from_json_str(c.as_str()),
|
||||
Err(e) => bail!("Failed to read {path}. {e}"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_yaml_str(yaml: &str) -> Result<Value> {
|
||||
Ok(serde_yaml::from_str(yaml)?)
|
||||
}
|
||||
|
||||
pub fn from_yaml_file(path: &String) -> Result<Value> {
|
||||
match std::fs::read_to_string(path) {
|
||||
Ok(c) => Self::from_yaml_str(c.as_str()),
|
||||
Err(e) => bail!("Failed to read {path}. {e}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Value {
|
||||
|
||||
Reference in New Issue
Block a user