Enum algorithmia::prelude::AlgoInput
[−]
[src]
pub enum AlgoInput<'a> { Text(Cow<'a, str>), Binary(Cow<'a, [u8]>), Json(Cow<'a, JsonValue>), }
Types that can be used as input to an algorithm
Variants
Text(Cow<'a, str>)
Data that will be sent with Content-Type: text/plain
Binary(Cow<'a, [u8]>)
Data that will be sent with Content-Type: application/octet-stream
Json(Cow<'a, JsonValue>)
Data that will be sent with Content-Type: application/json
Methods
impl<'a> AlgoInput<'a>
[src]
fn as_string(&self) -> Option<&str>
If the AlgoInput
is text (or a valid JSON string), returns the associated text
fn as_json(&'a self) -> Option<Cow<'a, JsonValue>>
If the AlgoInput
is Json (or JSON encodable text), returns the associated JSON string
For AlgoInput::Json
, this returns the borrowed Json
.
For the AlgoInput::Text
variant, the text is wrapped into an owned Json::String
.
fn as_bytes(&self) -> Option<&[u8]>
If the AlgoInput
is binary, returns the associated byte slice
fn decode<D: Deserialize>(&self) -> Result<D>
If the AlgoInput
is valid JSON, decode it to a particular type
Trait Implementations
impl<'a> From<()> for AlgoInput<'a>
[src]
impl<'a> From<&'a str> for AlgoInput<'a>
[src]
impl<'a> From<&'a [u8]> for AlgoInput<'a>
[src]
impl<'a> From<String> for AlgoInput<'a>
[src]
impl<'a> From<Vec<u8>> for AlgoInput<'a>
[src]
impl<'a> From<JsonValue> for AlgoInput<'a>
[src]
impl<'a, S: Serialize> From<&'a S> for AlgoInput<'a>
[src]
fn from(object: &'a S) -> Self
Performs the conversion.
impl<'a> From<AlgoOutput> for AlgoInput<'a>
[src]
fn from(output: AlgoOutput) -> Self
Performs the conversion.