Struct hcl::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
sourceimpl BlockBuilder
impl BlockBuilder
sourcepub fn new<I>(identifier: I) -> BlockBuilder where
I: Into<String>,
pub fn new<I>(identifier: I) -> BlockBuilder where
I: Into<String>,
Creates a new BlockBuilder to start building a new Block with the provided
identifier.
sourcepub fn add_label<L>(self, label: L) -> BlockBuilder where
L: Into<BlockLabel>,
pub fn add_label<L>(self, label: L) -> BlockBuilder where
L: Into<BlockLabel>,
Adds a BlockLabel.
Consumes self and returns a new BlockBuilder.
sourcepub fn add_labels<I>(self, iter: I) -> BlockBuilder where
I: IntoIterator,
I::Item: Into<BlockLabel>,
pub fn add_labels<I>(self, iter: I) -> BlockBuilder where
I: IntoIterator,
I::Item: Into<BlockLabel>,
Adds BlockLabels from an iterator.
Consumes self and returns a new BlockBuilder.
sourcepub fn add_attribute<A>(self, attr: A) -> BlockBuilder where
A: Into<Attribute>,
pub fn add_attribute<A>(self, attr: A) -> BlockBuilder where
A: Into<Attribute>,
Adds an Attribute to the block body.
Consumes self and returns a new BlockBuilder.
sourcepub fn add_attributes<I>(self, iter: I) -> BlockBuilder where
I: IntoIterator,
I::Item: Into<Attribute>,
pub fn add_attributes<I>(self, iter: I) -> BlockBuilder where
I: IntoIterator,
I::Item: Into<Attribute>,
Adds Attributes to the block body from an iterator.
Consumes self and returns a new BlockBuilder.
sourcepub fn add_block<B>(self, block: B) -> BlockBuilder where
B: Into<Block>,
pub fn add_block<B>(self, block: B) -> BlockBuilder where
B: Into<Block>,
Adds another Block to the block body.
Consumes self and returns a new BlockBuilder.
sourcepub fn add_blocks<I>(self, iter: I) -> BlockBuilder where
I: IntoIterator,
I::Item: Into<Block>,
pub fn add_blocks<I>(self, iter: I) -> BlockBuilder where
I: IntoIterator,
I::Item: Into<Block>,
Adds Blocks to the block body from an iterator.
Consumes self and returns a new BlockBuilder.
sourcepub fn add_structure<S>(self, structure: S) -> BlockBuilder where
S: Into<Structure>,
pub fn add_structure<S>(self, structure: S) -> BlockBuilder where
S: Into<Structure>,
Adds a Structure to the block body.
Consumes self and returns a new BlockBuilder.
sourcepub fn add_structures<I>(self, iter: I) -> BlockBuilder where
I: IntoIterator,
I::Item: Into<Structure>,
pub fn add_structures<I>(self, iter: I) -> BlockBuilder where
I: IntoIterator,
I::Item: Into<Structure>,
Adds Structures to the block body from an iterator.
Consumes self and returns a new BlockBuilder.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for BlockBuilder
impl Send for BlockBuilder
impl Sync for BlockBuilder
impl Unpin for BlockBuilder
impl UnwindSafe for BlockBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more