pub struct SystemOne<'a, S, T: ?Sized, A = Answers> { /* private fields */ }Expand description
A System One request, ready to be configured and sent.
Made by Client::system_one. A is what the answers decode into:
Answers, a lookup by question name, unless typed
names a type of the caller’s own.
Nothing is checked or encoded until send: the methods
never fail, and a header or a body member that cannot be sent is reported
by send.
Implementations§
Source§impl<'a, S, T, A> SystemOne<'a, S, T, A>where
T: ?Sized,
impl<'a, S, T, A> SystemOne<'a, S, T, A>where
T: ?Sized,
Sourcepub fn model(self, model: impl Into<Cow<'a, str>>) -> Self
pub fn model(self, model: impl Into<Cow<'a, str>>) -> Self
The model to ask, instead of the client’s default.
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
The deadline of each attempt of this call, instead of the client’s.
Sourcepub fn no_timeout(self) -> Self
pub fn no_timeout(self) -> Self
No deadline on any attempt of this call.
Sourcepub fn header(
self,
name: impl Into<Cow<'a, str>>,
value: impl Into<Cow<'a, str>>,
) -> Self
pub fn header( self, name: impl Into<Cow<'a, str>>, value: impl Into<Cow<'a, str>>, ) -> Self
A header for this call only. It replaces a client default of the same
name; the SDK’s own headers still win over it, as they do over a
default, and a later header of the same name replaces an earlier one.
The headers the SDK or its transport owns are dropped without an
error, as they are from a default; see
ClientBuilder::default_header
for the list, and for what Host does.
Sourcepub fn retry(self, policy: RetryPolicy) -> Self
pub fn retry(self, policy: RetryPolicy) -> Self
The retry policy of this call, in place of the client’s; the client and its other calls keep theirs.
Sourcepub fn extra_body<V>(self, name: impl Into<Cow<'a, str>>, value: &V) -> Self
pub fn extra_body<V>(self, name: impl Into<Cow<'a, str>>, value: &V) -> Self
A top-level member of the request body beside state, model and
questions, for a parameter the API has and this SDK does not model.
Merging is last-write-wins, as in the Python SDK: a later member of
the same name replaces an earlier one, and a member named state,
model or questions replaces that built-in one in place. The value
is encoded now; a value that cannot be encoded fails the call when it
is sent.
Source§impl<S, T, A> SystemOne<'_, S, T, A>
impl<S, T, A> SystemOne<'_, S, T, A>
Sourcepub async fn send(self) -> Result<SystemOneResponse<A>, Error>
pub async fn send(self) -> Result<SystemOneResponse<A>, Error>
Sends the request and decodes the answer, retrying a failure as the call’s retry policy, or else the client’s, says.
The body is encoded once: every attempt sends the same bytes. When retrying stops, the error is the one the last attempt failed with.
§Errors
ErrorKind::InvalidRequest, before anything is sent: a header that is not a valid header, a deadline of zero, astatethat is not a JSON string, object or array, or a value that cannot be encoded as JSON.ErrorKind::Apifor a status outside 2xx.ErrorKind::Timeoutwhen the attempt ran past its deadline.ErrorKind::Connectionwhen no response could be read: the connection failed or broke.ErrorKind::ResponseTooLargewhen a success response’s body was larger than the client’s limit.ErrorKind::ResponseValidationwhen the body does not decode intoA.