pub struct Export { /* private fields */ }
Expand description
Abstraction for the result of local computation. It is an AST decorated with the computation value.
Implementations§
source§impl Export
impl Export
sourcepub fn put<A: 'static>(&mut self, path: Path, value: A)
pub fn put<A: 'static>(&mut self, path: Path, value: A)
Inserts a value in the Export at the given Path.
Arguments
path
- The Path where to insert the value.value
- The value to insert.
Generic Parameters
A
- The type of the value to insert. It must have a'static
lifetime.
sourcepub fn put_lazy<A: 'static, F>(&mut self, path: Path, fun: F)where
F: FnOnce() -> A,
pub fn put_lazy<A: 'static, F>(&mut self, path: Path, fun: F)where
F: FnOnce() -> A,
Inserts a value in the Export at the given Path. The value is calculated from the provided function.
Arguments
path
- The Path where to insert the value.fun
- The function from which we calculate the value to insert.
Generic Parameters
A
- The type of the value to insert. It must have a'static
lifetime.F
- The type of the function from which the value is calculated.
sourcepub fn put_lazy_and_return<A: 'static + Clone, F>(
&mut self,
path: Path,
fun: F
) -> Awhere
F: FnOnce() -> A,
pub fn put_lazy_and_return<A: 'static + Clone, F>(
&mut self,
path: Path,
fun: F
) -> Awhere
F: FnOnce() -> A,
Inserts a value in the Export at the given Path. The value is calculated from the provided function and then returned to the caller.
Arguments
path
- The Path where to insert the value.fun
- The function from which we calculate the value to insert.
Generic Parameters
A
- The type of the value to insert. It must have a'static
lifetime.F
- The type of the function from which the value is calculated.
Returns
The calculated value.
sourcepub fn get<A: 'static + FromStr + Clone>(&self, path: &Path) -> Result<A>
pub fn get<A: 'static + FromStr + Clone>(&self, path: &Path) -> Result<A>
Returns the value at the given Path.
Arguments
path
- The Path where to get the value.
Generic Parameters
A
- The type of the value to get to return. It must have a'static
lifetime.
Returns
The value at the given Path.
sourcepub fn root<A: 'static + FromStr + Clone>(&self) -> A
pub fn root<A: 'static + FromStr + Clone>(&self) -> A
Obtain the root value. This function may panic, so it is preferable to use the non-panicking counterpart Export::root_as_result
Generic Parameters
A
- The type of the value to return. It must have a'static
lifetime.
Returns
The root value.
Panics
- Panics if there is not a root value (a value at the empty Path).
- Panics if the type of the root value is not the same as the type of the requested value.
sourcepub fn root_as_result<A: 'static + FromStr + Clone>(&self) -> Result<A>
pub fn root_as_result<A: 'static + FromStr + Clone>(&self) -> Result<A>
Obtain the root value. This method is the non-panicking version of Export::root
Generic Parameters
A
- The type of the value to return. It must have a'static
lifetime.
Returns
A Result containing the root value if present and an error otherwise.