[][src]Trait algorithmia::entrypoint::EntryPoint

pub trait EntryPoint: Default {
    fn apply_str(&mut self, text: &str) -> Result<AlgoIo, Box<dyn StdError>> { ... }
fn apply_json(&mut self, json: &Value) -> Result<AlgoIo, Box<dyn StdError>> { ... }
fn apply_bytes(&mut self, bytes: &[u8]) -> Result<AlgoIo, Box<dyn StdError>> { ... }
fn apply(&mut self, input: AlgoIo) -> Result<AlgoIo, Box<dyn StdError>> { ... } }

Implementing an algorithm involves overriding at least one of these methods

Provided methods

fn apply_str(&mut self, text: &str) -> Result<AlgoIo, Box<dyn StdError>>

Override to handle string input

fn apply_json(&mut self, json: &Value) -> Result<AlgoIo, Box<dyn StdError>>

Override to handle JSON input (see also DecodedEntryPoint)

fn apply_bytes(&mut self, bytes: &[u8]) -> Result<AlgoIo, Box<dyn StdError>>

Override to handle binary input

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

The default implementation of this method calls apply_str, apply_json, or apply_bytes based on the input type.

  • AlgoIo::Text results in call to apply_str
  • AlgoIo::Json results in call to apply_json
  • AlgoIo::Binary results in call to apply_bytes

If that call returns anKind UnsupportedInput error, then this method method will may attempt to coerce the input into another type and attempt one more call:

  • AlgoIo::Text input will be JSON-encoded to call apply_json
  • AlgoIo::Json input will be parse to see it can call apply_str
Loading content...

Implementors

impl<T> EntryPoint for T where
    T: DecodedEntryPoint
[src]

fn apply_str(&mut self, text: &str) -> Result<AlgoIo, Box<dyn StdError>>[src]

fn apply_json(&mut self, json: &Value) -> Result<AlgoIo, Box<dyn StdError>>[src]

fn apply_bytes(&mut self, bytes: &[u8]) -> Result<AlgoIo, Box<dyn StdError>>[src]

Loading content...