pub struct BodyBuilder(/* private fields */);
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) -> BodyBuilder
pub fn add_attribute<A>(self, attr: A) -> BodyBuilder
Adds an Attribute
to the body.
Consumes self
and returns a new BodyBuilder
.
Sourcepub fn add_attributes<I>(self, iter: I) -> BodyBuilder
pub fn add_attributes<I>(self, iter: I) -> BodyBuilder
Adds Attribute
s to the body from an iterator.
Consumes self
and returns a new BodyBuilder
.
Sourcepub fn add_block<B>(self, block: B) -> BodyBuilder
pub fn add_block<B>(self, block: B) -> BodyBuilder
Adds a Block
to the body.
Consumes self
and returns a new BodyBuilder
.
Sourcepub fn add_blocks<I>(self, iter: I) -> BodyBuilder
pub fn add_blocks<I>(self, iter: I) -> BodyBuilder
Adds Block
s to the body from an iterator.
Consumes self
and returns a new BodyBuilder
.
Sourcepub fn add_structure<S>(self, structure: S) -> BodyBuilder
pub fn add_structure<S>(self, structure: S) -> BodyBuilder
Adds a Structure
to the body.
Consumes self
and returns a new BodyBuilder
.
Sourcepub fn add_structures<I>(self, iter: I) -> BodyBuilder
pub fn add_structures<I>(self, iter: I) -> BodyBuilder
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
Auto Trait Implementations§
impl Freeze for BodyBuilder
impl RefUnwindSafe for BodyBuilder
impl Send for BodyBuilder
impl Sync for BodyBuilder
impl Unpin for BodyBuilder
impl UnwindSafe for BodyBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more