pub trait RequestDelete: Request {
    fn parse_inner_response(
        request: Option<Self>,
        uri: &Uri,
        response: &str,
        status: StatusCode
    ) -> Result<Response<Self, <Self as Request>::Response>, HelixRequestDeleteError>
    where
        Self: Sized
; fn create_request(
        &self,
        token: &str,
        client_id: &str
    ) -> Result<Request<Bytes>, CreateRequestError> { ... } fn parse_response<B: Into<Bytes>>(
        request: Option<Self>,
        uri: &Uri,
        response: Response<B>
    ) -> Result<Response<Self, <Self as Request>::Response>, HelixRequestDeleteError>
    where
        Self: Sized
, { ... } }
Available on crate feature helix only.
Expand description

Helix endpoint DELETEs information

Required Methods

Parse a response string into the response.

Provided Methods

Create a http::Request from this Request in your client

Examples found in repository?
src/helix/client.rs (line 201)
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
    pub async fn req_delete<R, D, T>(
        &'a self,
        request: R,
        token: &T,
    ) -> Result<Response<R, D>, ClientRequestError<<C as crate::HttpClient<'a>>::Error>>
    where
        R: Request<Response = D> + Request + RequestDelete,
        D: serde::de::DeserializeOwned + PartialEq,
        T: TwitchToken + ?Sized,
    {
        let req = request.create_request(token.token().secret(), token.client_id().as_str())?;
        let uri = req.uri().clone();
        let response = self
            .client
            .req(req)
            .await
            .map_err(ClientRequestError::RequestError)?
            .into_response_vec()
            .await?;
        <R>::parse_response(Some(request), &uri, response).map_err(Into::into)
    }
More examples
Hide additional examples
src/helix/client/custom.rs (line 251)
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
    pub async fn req_delete_custom<'d, R, D, T, F>(
        &'a self,
        request: R,
        token: &T,
        function: F,
    ) -> Result<CustomResponse<'d, R, D>, ClientRequestError<<C as crate::HttpClient<'a>>::Error>>
    where
        R: Request + RequestDelete,
        D: serde::de::Deserialize<'d> + 'd,
        T: TwitchToken + ?Sized,
        C: Send,
        F: Fn(&R, &http::Uri, &str, http::StatusCode) -> Result<(), HelixRequestDeleteError>,
    {
        let req = request.create_request(token.token().secret(), token.client_id().as_str())?;
        let uri = req.uri().clone();
        let response = self
            .client
            .req(req)
            .await
            .map_err(ClientRequestError::RequestError)?
            .into_response_bytes()
            .await?;
        {
            let uri = &uri;
            let text = std::str::from_utf8(response.body()).map_err(|e| {
                HelixRequestDeleteError::Utf8Error(response.body().clone(), e, uri.clone())
            })?;
            if let Ok(HelixRequestError {
                error,
                status,
                message,
            }) = parse_json::<HelixRequestError>(text, false)
            {
                return Err(HelixRequestDeleteError::Error {
                    error,
                    status: status.try_into().unwrap_or(http::StatusCode::BAD_REQUEST),
                    message,
                    uri: uri.clone(),
                    body: response.body().clone(),
                }
                .into());
            }
            function(&request, uri, text, response.status())?;
            let response: CustomInnerResponse<'_> = crate::parse_json(text, true).map_err(|e| {
                HelixRequestPatchError::DeserializeError(
                    text.to_owned(),
                    e,
                    uri.clone(),
                    response.status(),
                )
            })?;
            Ok(CustomResponse {
                pagination: response.pagination.cursor,
                request: Some(request),
                total: response.total,
                other: response.other,
                raw_data: response.data.to_owned(),
                pd: <_>::default(),
            })
        }
    }

Parse response.

Notes

Pass in the request to enable pagination if supported.

Examples found in repository?
src/helix/client.rs (line 210)
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
    pub async fn req_delete<R, D, T>(
        &'a self,
        request: R,
        token: &T,
    ) -> Result<Response<R, D>, ClientRequestError<<C as crate::HttpClient<'a>>::Error>>
    where
        R: Request<Response = D> + Request + RequestDelete,
        D: serde::de::DeserializeOwned + PartialEq,
        T: TwitchToken + ?Sized,
    {
        let req = request.create_request(token.token().secret(), token.client_id().as_str())?;
        let uri = req.uri().clone();
        let response = self
            .client
            .req(req)
            .await
            .map_err(ClientRequestError::RequestError)?
            .into_response_vec()
            .await?;
        <R>::parse_response(Some(request), &uri, response).map_err(Into::into)
    }

Implementors