hcl

Module structure

Source
Expand description

Types to represent the HCL structural sub-language.

The main types in this module are:

  • Attribute: represent an HCL attribute
  • Block: represent an HCL block
  • BlockBuilder: provides functionality for building Blocks
  • Body: represent the body of an HCL configuration or block
  • BodyBuilder: provides functionality for building Bodys

§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 HCL Block.
  • Represents an HCL config file body.
  • BodyBuilder builds a HCL Body.

Enums§