pub struct Request<T, E> { /* private fields */ }Expand description
The one request builder: a method, a path and its query, an optional JSON
body, the Authenticator that signs it and the
Costs it charges the client’s throttle.
send runs it on HttpClient::send, decodes the body as
T, and turns an unsuccessful response into E.
Implementations§
Source§impl<T, E> Request<T, E>
impl<T, E> Request<T, E>
Sourcepub fn new(http_client: HttpClient, path: impl Into<String>) -> Self
pub fn new(http_client: HttpClient, path: impl Into<String>) -> Self
Create a new GET request
Sourcepub fn authenticator(self, auth: Arc<DynAuthenticator<'static>>) -> Self
pub fn authenticator(self, auth: Arc<DynAuthenticator<'static>>) -> Self
Sign every attempt with auth.
Source§impl<T, E: From<ApiError>> Request<T, E>
impl<T, E: From<ApiError>> Request<T, E>
Sourcepub fn body<B: Serialize + ?Sized>(self, body: &B) -> Result<Self, E>
pub fn body<B: Serialize + ?Sized>(self, body: &B) -> Result<Self, E>
Send body as JSON, with Content-Type: application/json.
The body is serialised once, here, through serde_json::Value, so
every attempt sends, and an authenticator signs, the same bytes. A
Value sorts an object’s keys, so those bytes need not follow the
struct’s field order.
§Errors
ApiError::Serialization when body does not serialise.
Source§impl<T: DeserializeOwned, E: RequestError> Request<T, E>
impl<T: DeserializeOwned, E: RequestError> Request<T, E>
Sourcepub async fn send_raw(self) -> Result<Response, E>
pub async fn send_raw(self) -> Result<Response, E>
Execute the request and return raw response
It runs on HttpClient::send, so it is throttled, gated, signed,
retried and held by the client’s hooks. A response that is not a 2xx
is never returned: it reaches E as ApiError::Response.
Trait Implementations§
Source§impl<T, E> QueryBuilder for Request<T, E>
impl<T, E> QueryBuilder for Request<T, E>
Source§fn add_query(&mut self, key: String, value: String)
fn add_query(&mut self, key: String, value: String)
Source§fn query(self, key: impl Into<String>, value: impl ToString) -> Self
fn query(self, key: impl Into<String>, value: impl ToString) -> Self
self for chaining.