pub trait StreamTask {
type Output: Send;
type ResponseBody: for<'de> Deserialize<'de> + Send;
// Required methods
fn build_request(
&self,
client: &Client,
base: &str,
model: &str,
) -> RequestBuilder;
fn body_to_output(
&self,
response: Self::ResponseBody,
) -> Option<Self::Output>;
// Provided method
fn with_model<'a>(&'a self, model: &'a str) -> MethodJob<'a, Self>
where Self: Sized { ... }
}
Expand description
A task send to the Aleph Alpha Api using the http client. Requires to specify a model before it can be executed. Will return a stream of results.
Required Associated Types§
Sourcetype Output: Send
type Output: Send
Output returned by crate::Client::output_of
Sourcetype ResponseBody: for<'de> Deserialize<'de> + Send
type ResponseBody: for<'de> Deserialize<'de> + Send
Expected answer of the Aleph Alpha API
Required Methods§
Sourcefn build_request(
&self,
client: &Client,
base: &str,
model: &str,
) -> RequestBuilder
fn build_request( &self, client: &Client, base: &str, model: &str, ) -> RequestBuilder
Prepare the request for the Aleph Alpha API. Authentication headers can be assumed to be already set.
Sourcefn body_to_output(&self, response: Self::ResponseBody) -> Option<Self::Output>
fn body_to_output(&self, response: Self::ResponseBody) -> Option<Self::Output>
Parses the response of the server into higher level structs for the user.
None
implies the output should be skipped.
Provided Methods§
Sourcefn with_model<'a>(&'a self, model: &'a str) -> MethodJob<'a, Self>where
Self: Sized,
fn with_model<'a>(&'a self, model: &'a str) -> MethodJob<'a, Self>where
Self: Sized,
Turn your task into [Job
] by annotating it with a model name.