Struct hcl::structure::BlockBuilder

source ·
pub struct BlockBuilder { /* private fields */ }
Expand description

BlockBuilder builds an HCL Block.

The builder allows to build the Block by adding labels, attributes and other nested blocks via chained method calls. A call to .build() produces the final Block.

Example

use hcl::Block;

let 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();

Implementations§

Creates a new BlockBuilder to start building a new Block with the provided identifier.

Adds a BlockLabel.

Consumes self and returns a new BlockBuilder.

Adds BlockLabels from an iterator.

Consumes self and returns a new BlockBuilder.

Adds an Attribute to the block body.

Consumes self and returns a new BlockBuilder.

Adds Attributes to the block body from an iterator.

Consumes self and returns a new BlockBuilder.

Adds another Block to the block body.

Consumes self and returns a new BlockBuilder.

Adds Blocks to the block body from an iterator.

Consumes self and returns a new BlockBuilder.

Adds a Structure to the block body.

Consumes self and returns a new BlockBuilder.

Adds Structures to the block body from an iterator.

Consumes self and returns a new BlockBuilder.

Consumes self and builds the Block from the items added via the builder methods.

Trait Implementations§

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.