ensan/
lib.rs

1#![doc = include_str!("../README.md")]
2#![warn(clippy::complexity)]
3#![warn(clippy::correctness)]
4#![warn(clippy::nursery)]
5#![warn(clippy::pedantic)]
6#![warn(clippy::perf)]
7#![warn(clippy::style)]
8#![warn(clippy::suspicious)]
9// followings are from clippy::restriction
10#![warn(clippy::missing_errors_doc)]
11#![warn(clippy::missing_panics_doc)]
12#![warn(clippy::missing_safety_doc)]
13#![warn(clippy::unwrap_used)]
14#![warn(clippy::expect_used)]
15#![warn(clippy::format_push_string)]
16#![warn(clippy::get_unwrap)]
17#![allow(clippy::missing_inline_in_public_items)]
18#![allow(clippy::implicit_return)]
19#![allow(clippy::blanket_clippy_restriction_lints)]
20#![allow(clippy::pattern_type_mismatch)]
21pub mod engine;
22pub mod errors;
23pub mod functions;
24pub mod tests;
25
26pub use engine::Engine;
27pub use errors::Error;
28
29/// Quickly evaluate an HCL file
30///
31/// Outputs a fully-evaluated `hcl::Body` object, which is `hcl-rs`'s representation of an HCL file.
32///
33/// This type also implements `serde::Deserialize`, so you can easily convert it to any format you want.
34///
35/// # Errors
36/// Failure to parse the HCL or evalutate any expressions would result in an error.
37///
38/// # Example
39///
40/// ```rust
41/// use hcl::Value;
42///
43/// let hcl = r#"
44/// var "foo" {
45///     bar = "baz"
46/// }
47/// test = var.foo.bar
48///
49/// "#;
50///
51/// let expected = r#"
52/// var "foo" {
53///     bar = "baz"
54/// }
55/// test = "baz"
56///
57/// "#;
58///
59/// let body = ensan::parse(hcl).unwrap();
60///
61/// let expected_body = hcl::from_str(expected).unwrap();
62///
63/// assert_eq!(body, expected_body);
64///
65/// ```
66///
67pub fn parse(s: impl AsRef<str>) -> Result<hcl::Body, Error> {
68    Engine::new().parse(s)
69}