Expand description
Types to represent the HCL structural sub-language.
The main types in this module are:
Attribute
: represent an HCL attributeBlock
: represent an HCL blockBlockBuilder
: provides functionality for buildingBlock
sBody
: represent the body of an HCL configuration or blockBodyBuilder
: provides functionality for buildingBody
s
§Examples
Building HCL structures:
use hcl::{Body, Block, BlockLabel};
let body = Body::builder()
.add_block(
Block::builder("resource")
.add_label("aws_s3_bucket")
.add_label("mybucket")
.add_attribute(("name", "mybucket"))
.add_block(
Block::builder("logging")
.add_attribute(("target_bucket", "mylogsbucket"))
.build()
)
.build()
)
.build();
let mut iter = body.attributes();
assert_eq!(iter.next(), None);
let mut iter = body.blocks();
let block = iter.next().unwrap();
assert_eq!(block.identifier(), "resource");
assert_eq!(
block.labels().first(),
Some(&BlockLabel::from("aws_s3_bucket")),
);
Modules§
- Iterators over HCL structures.
Structs§
- Represents an HCL attribute which consists of an attribute key and a value expression.
- Represents an HCL block which consists of a block identifier, zero or more block labels and a block body.
BlockBuilder
builds an HCLBlock
.- Represents an HCL config file body.
BodyBuilder
builds a HCLBody
.
Enums§
- Represents an HCL block label.
- Represents an HCL structure.