Struct hcl::structure::BodyBuilder
source · pub struct BodyBuilder(_);
Expand description
BodyBuilder
builds a HCL Body
.
The builder allows to build the Body
by adding attributes and other nested blocks via chained
method calls. A call to .build()
produces the final Body
.
Example
use hcl::{Body, Block};
let body = Body::builder()
.add_block(
Block::builder("resource")
.add_label("aws_s3_bucket")
.add_label("mybucket")
.add_attribute(("name", "mybucket"))
.build()
)
.build();
Implementations§
source§impl BodyBuilder
impl BodyBuilder
sourcepub fn add_attribute<A>(self, attr: A) -> BodyBuilderwhere
A: Into<Attribute>,
pub fn add_attribute<A>(self, attr: A) -> BodyBuilderwhere A: Into<Attribute>,
Adds an Attribute
to the body.
Consumes self
and returns a new BodyBuilder
.
sourcepub fn add_attributes<I>(self, iter: I) -> BodyBuilderwhere
I: IntoIterator,
I::Item: Into<Attribute>,
pub fn add_attributes<I>(self, iter: I) -> BodyBuilderwhere I: IntoIterator, I::Item: Into<Attribute>,
Adds Attribute
s to the body from an iterator.
Consumes self
and returns a new BodyBuilder
.
sourcepub fn add_block<B>(self, block: B) -> BodyBuilderwhere
B: Into<Block>,
pub fn add_block<B>(self, block: B) -> BodyBuilderwhere B: Into<Block>,
Adds a Block
to the body.
Consumes self
and returns a new BodyBuilder
.
sourcepub fn add_blocks<I>(self, iter: I) -> BodyBuilderwhere
I: IntoIterator,
I::Item: Into<Block>,
pub fn add_blocks<I>(self, iter: I) -> BodyBuilderwhere I: IntoIterator, I::Item: Into<Block>,
Adds Block
s to the body from an iterator.
Consumes self
and returns a new BodyBuilder
.
sourcepub fn add_structure<S>(self, structure: S) -> BodyBuilderwhere
S: Into<Structure>,
pub fn add_structure<S>(self, structure: S) -> BodyBuilderwhere S: Into<Structure>,
Adds a Structure
to the body.
Consumes self
and returns a new BodyBuilder
.
sourcepub fn add_structures<I>(self, iter: I) -> BodyBuilderwhere
I: IntoIterator,
I::Item: Into<Structure>,
pub fn add_structures<I>(self, iter: I) -> BodyBuilderwhere I: IntoIterator, I::Item: Into<Structure>,
Adds Structure
s to the body from an iterator.
Consumes self
and returns a new BodyBuilder
.
Trait Implementations§
source§impl Debug for BodyBuilder
impl Debug for BodyBuilder
source§impl Default for BodyBuilder
impl Default for BodyBuilder
source§fn default() -> BodyBuilder
fn default() -> BodyBuilder
Returns the “default value” for a type. Read more