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