diff options
-rw-r--r-- | src/client/commands.rs | 11 | ||||
-rw-r--r-- | src/client/mod.rs | 6 | ||||
-rw-r--r-- | src/client/types.rs | 23 |
3 files changed, 38 insertions, 2 deletions
diff --git a/src/client/commands.rs b/src/client/commands.rs new file mode 100644 index 0000000..3d9427d --- /dev/null +++ b/src/client/commands.rs @@ -0,0 +1,11 @@ +use super::types::*; +use super::ClientLike; +use crate::error::Result; +use serde_json::json; +use std::future::Future; + +impl super::Client { + pub fn get_me(&self) -> impl Future<Output = Result<User>> { + self.send(json!({"@type": "getMe"})) + } +} diff --git a/src/client/mod.rs b/src/client/mod.rs index fb27561..2a7806b 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -12,7 +12,9 @@ //! pub(crate) mod client_builder; +pub mod commands; mod responder; +pub mod types; use crate::error::Result; use crate::raw_ptr::TdPtr; @@ -166,7 +168,7 @@ impl ClientLike for Client { .tag() .and_then(|tagged| serde_json::to_value(tagged).map_err(|err| err.into())) .and_then(|serialized| { - self.sender.send(JoinStreams::NewRequest(( + self.sender.send(JoinStreams::NewRequest(( serialized, fut.response.clone() ))).map_err(|err| err.into()) @@ -175,6 +177,6 @@ impl ClientLike for Client { match maybe_sent { Ok(_) => fut, Err(err) => ResponseFuture::from_error(err) - } + } } } diff --git a/src/client/types.rs b/src/client/types.rs new file mode 100644 index 0000000..25f1226 --- /dev/null +++ b/src/client/types.rs @@ -0,0 +1,23 @@ +use serde_derive::{Deserialize, Serialize}; +use serde_json::Value as JsonValue; + +#[derive(Serialize, Deserialize, Debug, Default)] +pub struct User { + id: i32, + first_name: String, + last_name: String, + username: String, + phone_number: String, + status: JsonValue, + profile_photo: JsonValue, + is_contact: bool, + is_mutual_contact: bool, + is_verified: bool, + is_support: bool, + restriction_reason: String, + is_scam: bool, + have_access: bool, + #[serde(rename = "type")] + type_: JsonValue, + language_code: String, +} |