Skip to main content

ComputeOp

Trait ComputeOp 

Source
pub trait ComputeOp: Send + Sync {
    type Input;
    type Output;

    // Required methods
    fn name(&self) -> &'static str;
    fn execute(
        &self,
        input: Self::Input,
        backend: Backend,
    ) -> Result<Self::Output, TruenoError>;
    fn tokens(&self, input: &Self::Input) -> usize;

    // Provided method
    fn clone_input(&self, input: &Self::Input) -> Option<Self::Input>
       where Self::Input: Clone { ... }
}
Expand description

Trait for compute operations that can be wrapped in a ComputeBrick.

Required Associated Types§

Source

type Input

Input type for this operation

Source

type Output

Output type for this operation

Required Methods§

Source

fn name(&self) -> &'static str

Operation name for identification

Source

fn execute( &self, input: Self::Input, backend: Backend, ) -> Result<Self::Output, TruenoError>

Execute the operation on the given backend

Source

fn tokens(&self, input: &Self::Input) -> usize

Number of tokens this operation processes (for budget calculation)

Provided Methods§

Source

fn clone_input(&self, input: &Self::Input) -> Option<Self::Input>
where Self::Input: Clone,

Clone the input for verification (if needed)

Implementors§