twilight_http/response/marker.rs
1//! Markers denoting the type of response body.
2//!
3//! Markers are used depending on the type of response that Twilight expects
4//! from an endpoint. For example, [`DeleteRole`] responses have no body, so an
5//! [`EmptyBody`] marker is used in the [`Response`].
6//!
7//! [`DeleteRole`]: super::super::request::guild::role::DeleteRole
8//! [`Response`]: super::Response
9
10use std::marker::PhantomData;
11
12/// Marker that a response has no body. Responses with this marker can't be
13/// deserialized.
14///
15/// Requests like [`AddRoleToMember`] or [`DeleteRole`] use this.
16///
17/// [`AddRoleToMember`]: crate::request::guild::member::AddRoleToMember
18/// [`DeleteRole`]: crate::request::guild::role::DeleteRole
19#[derive(Clone, Debug, Eq, PartialEq)]
20#[non_exhaustive]
21pub struct EmptyBody;
22
23/// Marker that a response has a list of something.
24///
25/// May be used via the [`Response::models`].
26///
27/// [`Response::models`]: super::Response::<ListBody<T>>::models
28#[derive(Clone, Debug, Eq, PartialEq)]
29pub struct ListBody<T> {
30 phantom: PhantomData<T>,
31}
32
33#[cfg(test)]
34mod tests {
35 use super::{EmptyBody, ListBody};
36 use static_assertions::assert_impl_all;
37 use std::fmt::Debug;
38
39 assert_impl_all!(EmptyBody: Clone, Debug, Eq, PartialEq, Send, Sync);
40 assert_impl_all!(ListBody<String>: Clone, Debug, Eq, PartialEq, Send, Sync);
41}