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_edit::structure::{Attribute, Block, Body};
use hcl_edit::Ident;
let body = Body::builder()
.block(
Block::builder(Ident::new("resource"))
.labels(["aws_s3_bucket", "mybucket"])
.attribute(Attribute::new(Ident::new("name"), "mybucket"))
)
.build();
Implementations§
Source§impl BodyBuilder
impl BodyBuilder
Sourcepub fn attribute(self, attr: impl Into<Attribute>) -> BodyBuilder
pub fn attribute(self, attr: impl Into<Attribute>) -> BodyBuilder
Adds an Attribute
to the body.
Consumes self
and returns a new BodyBuilder
.
Sourcepub fn attributes<I>(self, iter: I) -> BodyBuilder
pub fn attributes<I>(self, iter: I) -> BodyBuilder
Adds Attribute
s to the body from an iterator.
Consumes self
and returns a new BodyBuilder
.
Sourcepub fn block(self, block: impl Into<Block>) -> BodyBuilder
pub fn block(self, block: impl Into<Block>) -> BodyBuilder
Adds a Block
to the body.
Consumes self
and returns a new BodyBuilder
.
Sourcepub fn blocks<I>(self, iter: I) -> BodyBuilder
pub fn blocks<I>(self, iter: I) -> BodyBuilder
Adds Block
s to the body from an iterator.
Consumes self
and returns a new BodyBuilder
.
Sourcepub fn structure(self, structure: impl Into<Structure>) -> BodyBuilder
pub fn structure(self, structure: impl Into<Structure>) -> BodyBuilder
Adds a Structure
to the body.
Consumes self
and returns a new BodyBuilder
.
Sourcepub fn structures<I>(self, iter: I) -> BodyBuilder
pub fn 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
Source§impl From<BodyBuilder> for Body
impl From<BodyBuilder> for Body
Source§fn from(builder: BodyBuilder) -> Self
fn from(builder: BodyBuilder) -> Self
Converts to this type from the input type.
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