Trait twitch_api_rs::requests::Request[][src]

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;

    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>>; #[must_use] 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,
        C: 'async_trait,
        'life0: 'async_trait,
        Self: Sync + 'async_trait
, { ... } }

Represents a request that can be made to the twitch api

Associated Types

type Headers: Headers[src]

The type that represents the headers sent with this request

type Parameters: Parameters[src]

The type that represents the query parameters sent with this request

type Body: Body[src]

The type that represents the body of this request

type Response: Response + 'static[src]

The type returned by a sucessful request, must be DeserializeOwned and have at least a static lifetime (owned).

type ErrorCodes: ErrorCodes + 'static[src]

The type that encapsulates the error codes that this endpoint can return, must have at least a static lifetime (owned).

Loading content...

Associated Constants

const ENDPOINT: &'static str[src]

Endpoint where the request is made

const METHOD: Method[src]

The method that this request will use

Loading content...

Required methods

fn builder() -> Self[src]

Get a builder for this method

fn headers(&self) -> &Self::Headers[src]

Get the Headers struct for this Request

Will only be called when Self::ready returns Ok(()) and may not fail in that case

fn parameters(&self) -> &Self::Parameters[src]

Get the Parameters struct for this Request

Will only be called when Self::ready returns Ok(()) and may not fail in that case

fn body(&self) -> &Self::Body[src]

Get the Body struct for this Request

Will only be called when Self::ready returns Ok(()) and may not fail in that case

fn ready(&self) -> Result<(), RequestError<Self::ErrorCodes>>[src]

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.

Loading content...

Provided methods

#[must_use]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,
    C: 'async_trait,
    'life0: 'async_trait,
    Self: Sync + 'async_trait, 
[src]

Make the request represented by this object. Only makes request if Self::ready returns Ok(()).

Loading content...

Implementors

impl Request for ClientAuthRequest[src]

type Headers = ()

type Parameters = ClientAuthRequestParams

type Body = ()

type Response = ClientAuthResponse

type ErrorCodes = CommonResponseCodes

impl<A> Request for GetChannelInformationRequest<A> where
    A: AuthToken + Sync
[src]

type Headers = A

type Parameters = Self

type Body = ()

type Response = GetChannelInformationResponse

type ErrorCodes = CommonResponseCodes

impl<A> Request for GetClipsRequest<A> where
    A: AuthToken + Sync
[src]

type Headers = A

type Parameters = Self

type Body = ()

type Response = GetClipsResponse

type ErrorCodes = CommonResponseCodes

impl<A> Request for GetUsersRequest<A> where
    A: AuthToken + Send
[src]

type Headers = A

type Parameters = Self

type Body = ()

type Response = GetUsersResponse

type ErrorCodes = CommonResponseCodes

Loading content...