modio/request/auth/
logout.rs

1use std::future::IntoFuture;
2
3use crate::client::Client;
4use crate::request::{Output, RequestBuilder, Route};
5use crate::response::{NoContent, ResponseFuture};
6
7/// Log out by revoking the current access token.
8pub struct Logout<'a> {
9    http: &'a Client,
10}
11
12impl<'a> Logout<'a> {
13    pub(crate) const fn new(http: &'a Client) -> Self {
14        Self { http }
15    }
16}
17
18impl IntoFuture for Logout<'_> {
19    type Output = Output<NoContent>;
20    type IntoFuture = ResponseFuture<NoContent>;
21
22    fn into_future(self) -> Self::IntoFuture {
23        let route = Route::OAuthLogout;
24        match RequestBuilder::from_route(&route).empty() {
25            Ok(req) => self.http.request(req),
26            Err(err) => ResponseFuture::failed(err),
27        }
28    }
29}