ruma_client_api/session/
logout.rs1pub mod v3 {
6 use ruma_common::{
11 api::{response, Metadata},
12 metadata,
13 };
14
15 metadata! {
16 method: POST,
17 rate_limited: false,
18 authentication: AccessToken,
19 history: {
20 1.0 => "/_matrix/client/r0/logout",
21 1.1 => "/_matrix/client/v3/logout",
22 }
23 }
24
25 #[derive(Debug, Clone, Default)]
27 #[cfg_attr(not(ruma_unstable_exhaustive_types), non_exhaustive)]
28 pub struct Request {}
29
30 impl Request {
31 pub fn new() -> Self {
33 Self {}
34 }
35 }
36
37 #[cfg(feature = "client")]
38 impl ruma_common::api::OutgoingRequest for Request {
39 type EndpointError = crate::Error;
40 type IncomingResponse = Response;
41
42 fn try_into_http_request<T: Default + bytes::BufMut>(
43 self,
44 base_url: &str,
45 access_token: ruma_common::api::SendAccessToken<'_>,
46 considering: &'_ ruma_common::api::SupportedVersions,
47 ) -> Result<http::Request<T>, ruma_common::api::error::IntoHttpError> {
48 let url = Self::make_endpoint_url(considering, base_url, &[], "")?;
49
50 http::Request::builder()
51 .method(Self::METHOD)
52 .uri(url)
53 .header(
54 http::header::AUTHORIZATION,
55 format!(
56 "Bearer {}",
57 access_token
58 .get_required_for_endpoint()
59 .ok_or(ruma_common::api::error::IntoHttpError::NeedsAuthentication)?,
60 ),
61 )
62 .body(T::default())
63 .map_err(Into::into)
64 }
65 }
66
67 #[cfg(feature = "server")]
68 impl ruma_common::api::IncomingRequest for Request {
69 type EndpointError = crate::Error;
70 type OutgoingResponse = Response;
71
72 fn try_from_http_request<B, S>(
73 request: http::Request<B>,
74 _path_args: &[S],
75 ) -> Result<Self, ruma_common::api::error::FromHttpRequestError>
76 where
77 B: AsRef<[u8]>,
78 S: AsRef<str>,
79 {
80 if request.method() != Self::METHOD {
81 return Err(ruma_common::api::error::FromHttpRequestError::MethodMismatch {
82 expected: Self::METHOD,
83 received: request.method().clone(),
84 });
85 }
86
87 Ok(Self {})
88 }
89 }
90
91 #[response(error = crate::Error)]
93 #[derive(Default)]
94 pub struct Response {}
95
96 impl Response {
97 pub fn new() -> Self {
99 Self {}
100 }
101 }
102}