Struct algorithmia::algo::Algorithm
[−]
[src]
pub struct Algorithm { /* fields omitted */ }
Algorithmia algorithm - intialized from the Algorithmia
builder
Methods
impl Algorithm
[src]
fn to_url(&self) -> Result<Url>
Get the API Endpoint URL for this Algtried orithm
fn to_algo_uri(&self) -> &AlgoUri
Get the Algorithmia algo URI for this Algorithm
fn pipe<'a, I>(&'a self, input_data: I) -> Result<AlgoResponse> where I: Into<AlgoInput<'a>>
Execute an algorithm with the specified input_data
.
input_data
can be any type which converts into AlgoInput
,
including strings, byte slices, and any serializable type.
To create serializable objects for complex input, annotate your type
with #[derive(Serialize)]
(see serde.rs for details).
If you want to send a raw, unparsed JSON string, use the pipe_json
method instead.
Examples
let client = Algorithmia::client("111112222233333444445555566"); let moving_avg = client.algo("timeseries/SimpleMovingAverage/0.1"); let input = (vec![0,1,2,3,15,4,5,6,7], 3); match moving_avg.pipe(&input) { Ok(response) => println!("{}", response.into_json().unwrap()), Err(err) => println!("ERROR: {}", err), };
fn pipe_json(&self, json_input: &str) -> Result<AlgoResponse>
Execute an algorithm with a raw JSON string as input.
While the pipe
method is more flexible in accepting different types
of input, and inferring the content type when making an API call,
pipe_json
explicitly sends the provided string with
Content-Type: application/json
making no attempt to verify that
the input is valid JSON. By contrast, calling pipe
with a string
would send it with Content-Type: text/plain
.
Examples
let client = Algorithmia::client("111112222233333444445555566"); let minmax = client.algo("codeb34v3r/FindMinMax/0.1"); let output = match minmax.pipe_json("[2,3,4]") { Ok(response) => response.into_json().unwrap(), Err(err) => panic!("{}", err), };
fn set_options(&mut self, options: AlgoOptions) -> &mut Algorithm
Builder method to explicitly configure options
fn timeout(&mut self, timeout: u32) -> &mut Algorithm
Builder method to configure the timeout in seconds
Examples
let client = Algorithmia::client("111112222233333444445555566"); client.algo("codeb34v3r/FindMinMax/0.1") .timeout(3) .pipe(vec![2,3,4]) .unwrap();
fn stdout(&mut self, stdout: bool) -> &mut Algorithm
Builder method to enabled or disable stdout in the response metadata
This has no affect unless authenticated as the owner of the algorithm