Trait algorithmia::algo::DecodedEntryPoint [] [src]

pub trait DecodedEntryPoint: Default {
    type Input: Deserialize;
    fn apply_decoded(
        &self,
        input: Self::Input
    ) -> Result<AlgoOutput, Box<StdError>>; }

Alternate implementation for EntryPoint that automatically decodes JSON input to the associate type

Examples

impl DecodedEntryPoint for Algo {
    // Expect input to be an array of 2 strings
    type Input = (String, String);
    fn apply_decoded(&self, input: Self::Input) -> Result<AlgoOutput, Box<Error>> {
        let msg = format!("{} - {}", input.0, input.1);
        Ok(msg.into())
    }
}

Associated Types

Specifies the type that the input will be automatically deserialized into

Required Methods

This method is an apply variant that will receive the decoded form of JSON input. If decoding failed, a DecoderError will be returned before this method is invoked.

Implementors