[][src]Trait algorithmia::entrypoint::DecodedEntryPoint

pub trait DecodedEntryPoint: Default {
    type Input: DeserializeOwned;
    fn apply_decoded(
        &mut self,
        input: Self::Input
    ) -> Result<AlgoIo, Box<dyn 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(&mut self, input: Self::Input) -> Result<AlgoIo, Box<Error>> {
        let msg = format!("{} - {}", input.0, input.1);
        Ok(msg.into())
    }
}

Associated Types

type Input: DeserializeOwned

Specifies the type that the input will be automatically deserialized into

Loading content...

Required methods

fn apply_decoded(
    &mut self,
    input: Self::Input
) -> Result<AlgoIo, Box<dyn StdError>>

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.

Loading content...

Implementors

Loading content...