Expand description

Types to represent HCL structures.

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::StringLit("aws_s3_bucket".into())),
);

Re-exports

pub use self::attribute::Attribute;
pub use self::block::Block;
pub use self::block::BlockBuilder;
pub use self::block::BlockLabel;
pub use self::body::Body;
pub use self::body::BodyBuilder;

Modules

Types to represent and build HCL attributes.

Types to represent and build HCL blocks.

Types to represent and build HCL body structures.

Enums

Represents an HCL structure.