From 2652216b90e62583d39ae5c20c7c6227c592e6f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=AC=E9=A3=8E?= <1770963469@qq.com> Date: Sat, 18 Nov 2023 11:57:02 +0800 Subject: [PATCH] Create input_user.rs --- lib/grammers-client/src/types/input_user.rs | 36 +++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 lib/grammers-client/src/types/input_user.rs diff --git a/lib/grammers-client/src/types/input_user.rs b/lib/grammers-client/src/types/input_user.rs new file mode 100644 index 00000000..09acdc8a --- /dev/null +++ b/lib/grammers-client/src/types/input_user.rs @@ -0,0 +1,36 @@ +use grammers_tl_types as tl; + +#[derive(Debug)] +pub struct InputUser(pub(crate) tl::enums::InputUser); + +impl InputUser { + pub fn _from_raw(raw: tl::enums::InputUser) -> Self { + Self(raw) + } + + pub fn _from_message(peer: tl::enums::InputPeer, msg_id: i32, user_id: i64) -> Self { + Self::_from_raw( + tl::types::InputUserFromMessage { + peer, + msg_id, + user_id, + } + .into(), + ) + } + + pub fn is_empty(&self) -> bool { + self.0 == tl::enums::InputUser::Empty + } + + pub fn is_self(&self) -> bool { + self.0 == tl::enums::InputUser::UserSelf + } +} + +#[cfg(feature = "unstable_raw")] +impl From for tl::enums::InputUser { + fn from(input_user: InputUser) -> Self { + input_user.0 + } +}