pub struct Template { /* private fields */ }
Expand description
The main type to represent the HCL template sub-languange.
A template behaves like an expression that always returns a string value. The different elements of the template are evaluated and combined into a single string to return.
See the module level
documentation for usage examples.
Implementations§
source§impl Template
impl Template
sourcepub fn from_expr(expr: &TemplateExpr) -> Result<Self>
pub fn from_expr(expr: &TemplateExpr) -> Result<Self>
Expands a raw template expression to a template.
Errors
Returns an error if the parsing of raw string templates fails or if the template expression contains string literals with invalid escape sequences.
sourcepub fn elements_mut(&mut self) -> &mut [Element]
pub fn elements_mut(&mut self) -> &mut [Element]
Returns a mutable reference to the template elements.
source§impl Template
impl Template
sourcepub fn add_element<T>(self, element: T) -> Templatewhere
T: Into<Element>,
pub fn add_element<T>(self, element: T) -> Templatewhere T: Into<Element>,
Adds a template element (literal, interpolation or directive) to the template.
sourcepub fn add_literal<T>(self, literal: T) -> Templatewhere
T: Into<String>,
pub fn add_literal<T>(self, literal: T) -> Templatewhere T: Into<String>,
Adds a literal to the template.
sourcepub fn add_interpolation<T>(self, interpolation: T) -> Templatewhere
T: Into<Interpolation>,
pub fn add_interpolation<T>(self, interpolation: T) -> Templatewhere T: Into<Interpolation>,
Adds an interpolation to the template.
sourcepub fn add_directive<T>(self, directive: T) -> Templatewhere
T: Into<Directive>,
pub fn add_directive<T>(self, directive: T) -> Templatewhere T: Into<Directive>,
Adds a directive to the template.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Template
impl<'de> Deserialize<'de> for Template
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Format for Template
impl Format for Template
source§fn format<W>(&self, fmt: &mut Formatter<'_, W>) -> Result<()>where
W: Write,
fn format<W>(&self, fmt: &mut Formatter<'_, W>) -> Result<()>where W: Write,
Formats a HCL structure using a formatter and writes the result to the provided writer. Read more
source§impl<T> FromIterator<T> for Templatewhere
T: Into<Element>,
impl<T> FromIterator<T> for Templatewhere T: Into<Element>,
source§fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = T>,
fn from_iter<I>(iter: I) -> Selfwhere I: IntoIterator<Item = T>,
Creates a value from an iterator. Read more
source§impl PartialEq<Template> for Template
impl PartialEq<Template> for Template
impl Eq for Template
impl StructuralEq for Template
impl StructuralPartialEq for Template
Auto Trait Implementations§
impl RefUnwindSafe for Template
impl Send for Template
impl Sync for Template
impl Unpin for Template
impl UnwindSafe for Template
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
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.