NodeWrapper

Trait NodeWrapper 

Source
pub trait NodeWrapper<T> {
    // Required methods
    fn calculate_wrapped_nodes(
        &self,
        parameters: &HashMap<&str, Parameter>,
    ) -> Result<T, CalculationError>;
    fn serialise(self) -> Result<Vec<u8>, SerialisationError>;

    // Provided method
    fn calculate(
        &self,
        parameters: Option<&HashMap<&str, Parameter>>,
    ) -> Result<T, CalculationError> { ... }
}

Required Methods§

Source

fn calculate_wrapped_nodes( &self, parameters: &HashMap<&str, Parameter>, ) -> Result<T, CalculationError>

This method triggers a calculation based on the instructions given by the nodes underlying the NodeWrapper. If the instruction expects parameters they need to be passed as a std::collections::HashMap. an empty std::collections::HashMap needs to be passed. The std::collections::HashMap expects variable names as keys and related variable values as std::collections::HashMap values. In contrast to NodeWrapper::calculate, an empty std::collections::HashMap needs to be passed to this method if the instruction does not expect any parameters. A calculation result of type [T] is returned in case of success, a calculation error of type [crate::calculation_error::CalculationError] otherwise.

Source

fn serialise(self) -> Result<Vec<u8>, SerialisationError>

This method serialises the whole instruction covered by this NodeWrapper into a binary format that can be deserialised into a crate::InstructionWrapper.

Provided Methods§

Source

fn calculate( &self, parameters: Option<&HashMap<&str, Parameter>>, ) -> Result<T, CalculationError>

This method triggers a calculation based on the instructions given by the nodes underlying the NodeWrapper. If the instruction expects parameters they need to be passed as a std::collections::HashMap wrapped inside an option. The std::collections::HashMap expects variable names as keys and related variable values as std::collections::HashMap values. A calculation result of type [T] is returned in case of success, a calculation error of type [crate::calculation_error::CalculationError] otherwise.

Implementors§