pub struct Data { /* private fields */ }Expand description
The Data struct is used to represent the raw execution result of a node in a template.
Data can currently be in one of three states:
- Empty: The execution was successful but there was no result associated. For example, value assignments (x = y)
- Success: The document data can be safely retrieved
- Failure: An error occurred executing this node
Implementations§
Source§impl<'a> Data
impl<'a> Data
Sourcepub fn inner_data(&self) -> &InnerData
pub fn inner_data(&self) -> &InnerData
Get reference to the inner value
Sourcepub fn inner_data_mut(&mut self) -> &mut InnerData
pub fn inner_data_mut(&mut self) -> &mut InnerData
Get reference to the inner value
Sourcepub fn into_inner(self) -> InnerData
pub fn into_inner(self) -> InnerData
Get reference to the inner value
Sourcepub fn render(self) -> Result<String>
pub fn render(self) -> Result<String>
Render this result
If the data is empty, an empty string is returned. If this data is in an error state, the error is returned Otherwise, the rendered string is returned
Sourcepub fn unwrap_err(self) -> TemplarError
pub fn unwrap_err(self) -> TemplarError
Unwrap the data error
§PANIC!
This will panic if this data struct is empty or does not contain an error
Sourcepub fn into_result(self) -> Result<Self>
pub fn into_result(self) -> Result<Self>
Convert the data into a Result
Sourcepub fn clone_result(&self) -> Result<Self>
pub fn clone_result(&self) -> Result<Self>
Clone this data into a new Result
Sourcepub fn to_result(&'a self) -> Result<&'a InnerData>
pub fn to_result(&'a self) -> Result<&'a InnerData>
Retrieve a result with a reference to the underlying document
pub fn from_result(result: Result<InnerData>) -> Data
Methods from Deref<Target = InnerData>§
pub fn is<T>(&self) -> boolwhere
T: DocumentConvertible<Q>,
pub fn get_path(&self, path: &[&Unstructured<T>]) -> &Unstructured<T>where
Unstructured<T>: Index<T>,
pub fn set_path<U>(&mut self, val: U, path: &[&Unstructured<T>])
pub fn set<U>(&mut self, val: U)where
U: Into<Unstructured<T>>,
pub fn replace<U>(&mut self, new_val: U) -> Unstructured<T>where
U: Into<Unstructured<T>>,
pub fn take(&mut self) -> Unstructured<T>
pub fn is_null(&self) -> bool
pub fn is_number(&self) -> bool
Sourcepub fn is_signed(&self) -> bool
pub fn is_signed(&self) -> bool
Returns true if the value is any signed integer (i8, i16, i32, i64)
Sourcepub fn is_unsigned(&self) -> bool
pub fn is_unsigned(&self) -> bool
Returns true if the value is any unsigned integer (u8, u16, u32, u64)
pub fn as_usize(&self) -> Option<usize>
Sourcepub fn merge(&mut self, other: Unstructured<T>)
pub fn merge(&mut self, other: Unstructured<T>)
Merge another document into this one, consuming both documents into the result. If this document is not a map or seq, it will be overwritten. If this document is a seq and the other is also a seq, the other seq will be appended to the end of this one. If the other document is not a seq, then it will be appended to the end of the sequence in this one. If this document is a map and the other document is also be a map, merging maps will cause values from the other document to overwrite this one. Otherwise, the value from the other document will overwrite this one.