pub fn from_reader<T, R>(reader: R) -> Result<T>where
T: DeserializeOwned,
R: Read,
Expand description
Deserialize an instance of type T
from an IO stream of HCL.
See the documentation of from_str
for more information.
§Example
use hcl::Value;
let input = r#"
some_attr = {
foo = [1, 2]
bar = true
}
some_block "some_block_label" {
attr = "value"
}
"#;
let expected = hcl::value!({
some_attr = {
foo = [1, 2]
bar = true
}
some_block = {
some_block_label = {
attr = "value"
}
}
});
let value: Value = hcl::from_reader(input.as_bytes())?;
assert_eq!(value, expected);
§Errors
This functions fails with an error if reading from the reader fails or if the data does not
match the structure of T
.