pub trait Request {
type Headers: Headers;
type Parameters: Parameters;
type Body: Body;
type Response: Response + 'static;
type ErrorCodes: ErrorCodes + 'static;
const ENDPOINT: &'static str;
const METHOD: Method;
// Required methods
fn builder() -> Self;
fn headers(&self) -> &Self::Headers;
fn parameters(&self) -> &Self::Parameters;
fn body(&self) -> &Self::Body;
fn ready(&self) -> Result<(), RequestError<Self::ErrorCodes>>;
// Provided method
fn make_request<'life0, 'async_trait, C>(
&'life0 self,
client: C,
) -> Pin<Box<dyn Future<Output = Result<Self::Response, RequestError<Self::ErrorCodes>>> + Send + 'async_trait>>
where C: Borrow<Client> + Send + 'async_trait,
Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
}
Expand description
Represents a request that can be made to the twitch api
Required Associated Constants§
Required Associated Types§
Sourcetype Parameters: Parameters
type Parameters: Parameters
The type that represents the query parameters sent with this request
Sourcetype Response: Response + 'static
type Response: Response + 'static
The type returned by a sucessful request, must be DeserializeOwned
and have at least a static lifetime (owned).
Sourcetype ErrorCodes: ErrorCodes + 'static
type ErrorCodes: ErrorCodes + 'static
The type that encapsulates the error codes that this endpoint can return, must have at least a static lifetime (owned).
Required Methods§
Sourcefn headers(&self) -> &Self::Headers
fn headers(&self) -> &Self::Headers
Get the Headers struct for this Request
Will only be called when Self::ready
returns Ok(())
and may not fail
in that case
Sourcefn parameters(&self) -> &Self::Parameters
fn parameters(&self) -> &Self::Parameters
Get the Parameters struct for this Request
Will only be called when Self::ready
returns Ok(())
and may not fail
in that case
Sourcefn body(&self) -> &Self::Body
fn body(&self) -> &Self::Body
Get the Body struct for this Request
Will only be called when Self::ready
returns Ok(())
and may not fail
in that case
Sourcefn ready(&self) -> Result<(), RequestError<Self::ErrorCodes>>
fn ready(&self) -> Result<(), RequestError<Self::ErrorCodes>>
Must return Ok(())
if and only if this request is ready to have
Self::make_request
called on it.
Should return RequestError::MalformedRequest
with a message in the case
that the request is not ready to be sent.
Called by Self::make_request
, error is propogated.
Provided Methods§
Sourcefn make_request<'life0, 'async_trait, C>(
&'life0 self,
client: C,
) -> Pin<Box<dyn Future<Output = Result<Self::Response, RequestError<Self::ErrorCodes>>> + Send + 'async_trait>>
fn make_request<'life0, 'async_trait, C>( &'life0 self, client: C, ) -> Pin<Box<dyn Future<Output = Result<Self::Response, RequestError<Self::ErrorCodes>>> + Send + 'async_trait>>
Make the request represented by this object. Only makes request if Self::ready
returns
Ok(())
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.