[][src]Struct templar::Data

pub struct Data { /* fields omitted */ }

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

impl<'a> Data[src]

pub fn empty() -> Data[src]

Create a new empty result

pub fn new<T: Into<InnerData>>(inner: T) -> Self[src]

Create new data value

pub fn inner_data(&self) -> &InnerData[src]

Get reference to the inner value

pub fn inner_data_mut(&mut self) -> &mut InnerData[src]

Get reference to the inner value

pub fn into_inner(self) -> InnerData[src]

Get reference to the inner value

pub fn render(self) -> Result<String>[src]

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

pub fn is_failed(&self) -> bool[src]

Check if this data struct has a failure

pub fn is_empty(&self) -> bool[src]

Check if this data struct is empty

pub fn unwrap(self) -> Self[src]

Unwrap the data contents

PANIC!

This will panic if this data struct is empty or contains an error

pub fn unwrap_err(self) -> TemplarError[src]

Unwrap the data error

PANIC!

This will panic if this data struct is empty or does not contain an error

pub fn into_result(self) -> Result<Self>[src]

Convert the data into a Result. In the case of empty data, an empty string is returned.

pub fn clone_result(&self) -> Result<Self>[src]

Clone this data into a new Result

pub fn to_result(&'a self) -> Result<&'a InnerData>[src]

Retrieve a result with a reference to the underlying document

pub fn from_result(result: Result<InnerData>) -> Data[src]

Trait Implementations

impl Clone for Data[src]

impl Debug for Data[src]

impl Deref for Data[src]

type Target = InnerData

The resulting type after dereferencing.

impl DerefMut for Data[src]

impl Display for Data[src]

impl<T: Into<InnerData>> From<T> for Data[src]

impl From<TemplarError> for Data[src]

impl UnstructuredDataTrait for Data[src]

type ErrorType = TemplarError

type OtherType = OtherData

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.