Trait algorithmia::algo::EntryPoint
[−]
[src]
pub trait EntryPoint: Default { fn apply_str(&self, text: &str) -> Result<AlgoOutput, Box<StdError>> { ... } fn apply_json(&self, json: &JsonValue) -> Result<AlgoOutput, Box<StdError>> { ... } fn apply_bytes(&self, bytes: &[u8]) -> Result<AlgoOutput, Box<StdError>> { ... } fn apply(&self, input: AlgoInput) -> Result<AlgoOutput, Box<StdError>> { ... } }
Implementing an algorithm involves overriding at least one of these methods
Provided Methods
fn apply_str(&self, text: &str) -> Result<AlgoOutput, Box<StdError>>
Override to handle string input
fn apply_json(&self, json: &JsonValue) -> Result<AlgoOutput, Box<StdError>>
Override to handle JSON input (see also DecodedEntryPoint
)
fn apply_bytes(&self, bytes: &[u8]) -> Result<AlgoOutput, Box<StdError>>
Override to handle binary input
fn apply(&self, input: AlgoInput) -> Result<AlgoOutput, Box<StdError>>
The default implementation of this method calls
apply_str
, apply_json
, or apply_bytes
based on the input type.
AlgoInput::Text
results in call toapply_str
AlgoInput::Json
results in call toapply_json
AlgoInput::Binary
results in call toapply_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:
AlgoInput::Text
input will be JSON-encoded to callapply_json
AlgoInput::Json
input will be parse to see it can callapply_str
Implementors
impl<T> EntryPoint for T where
T: DecodedEntryPoint,