mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-23 15:01:45 +01:00
Remove get_updates_fault_tolerant
and SemiparsedVec
This commit is contained in:
parent
648b5b7377
commit
59720c1e0b
13 changed files with 9 additions and 123 deletions
|
@ -106,8 +106,7 @@ where
|
||||||
set_sticker_set_thumb, send_invoice, answer_shipping_query,
|
set_sticker_set_thumb, send_invoice, answer_shipping_query,
|
||||||
answer_pre_checkout_query, set_passport_data_errors, send_game,
|
answer_pre_checkout_query, set_passport_data_errors, send_game,
|
||||||
set_game_score, set_game_score_inline, get_game_high_scores,
|
set_game_score, set_game_score_inline, get_game_high_scores,
|
||||||
approve_chat_join_request, decline_chat_join_request,
|
approve_chat_join_request, decline_chat_join_request => f, fty
|
||||||
get_updates_fault_tolerant => f, fty
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,8 +113,7 @@ where
|
||||||
set_sticker_set_thumb, send_invoice, answer_shipping_query,
|
set_sticker_set_thumb, send_invoice, answer_shipping_query,
|
||||||
answer_pre_checkout_query, set_passport_data_errors, send_game,
|
answer_pre_checkout_query, set_passport_data_errors, send_game,
|
||||||
set_game_score, set_game_score_inline, get_game_high_scores,
|
set_game_score, set_game_score_inline, get_game_high_scores,
|
||||||
approve_chat_join_request, decline_chat_join_request,
|
approve_chat_join_request, decline_chat_join_request => f, fty
|
||||||
get_updates_fault_tolerant => f, fty
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -182,8 +182,7 @@ where
|
||||||
set_sticker_set_thumb, send_invoice, answer_shipping_query,
|
set_sticker_set_thumb, send_invoice, answer_shipping_query,
|
||||||
answer_pre_checkout_query, set_passport_data_errors, send_game,
|
answer_pre_checkout_query, set_passport_data_errors, send_game,
|
||||||
set_game_score, set_game_score_inline, get_game_high_scores,
|
set_game_score, set_game_score_inline, get_game_high_scores,
|
||||||
approve_chat_join_request, decline_chat_join_request,
|
approve_chat_join_request, decline_chat_join_request => fwd_erased, fty
|
||||||
get_updates_fault_tolerant => fwd_erased, fty
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -692,8 +691,6 @@ trait ErasableRequester<'a> {
|
||||||
user_id: i64,
|
user_id: i64,
|
||||||
target: TargetMessage,
|
target: TargetMessage,
|
||||||
) -> ErasedRequest<'a, GetGameHighScores, Self::Err>;
|
) -> ErasedRequest<'a, GetGameHighScores, Self::Err>;
|
||||||
|
|
||||||
fn get_updates_fault_tolerant(&self) -> ErasedRequest<'a, GetUpdatesFaultTolerant, Self::Err>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, B> ErasableRequester<'a> for B
|
impl<'a, B> ErasableRequester<'a> for B
|
||||||
|
@ -1401,8 +1398,4 @@ where
|
||||||
) -> ErasedRequest<'a, GetGameHighScores, Self::Err> {
|
) -> ErasedRequest<'a, GetGameHighScores, Self::Err> {
|
||||||
Requester::get_game_high_scores(self, user_id, target).erase()
|
Requester::get_game_high_scores(self, user_id, target).erase()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_updates_fault_tolerant(&self) -> ErasedRequest<'a, GetUpdatesFaultTolerant, Self::Err> {
|
|
||||||
Requester::get_updates_fault_tolerant(self).erase()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,8 +117,7 @@ impl<B: Requester> Requester for DefaultParseMode<B> {
|
||||||
set_sticker_set_thumb, send_invoice, answer_shipping_query,
|
set_sticker_set_thumb, send_invoice, answer_shipping_query,
|
||||||
answer_pre_checkout_query, set_passport_data_errors, send_game,
|
answer_pre_checkout_query, set_passport_data_errors, send_game,
|
||||||
set_game_score, set_game_score_inline, get_game_high_scores,
|
set_game_score, set_game_score_inline, get_game_high_scores,
|
||||||
approve_chat_join_request, decline_chat_join_request,
|
approve_chat_join_request, decline_chat_join_request => fid, fty
|
||||||
get_updates_fault_tolerant => fid, fty
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -621,7 +621,7 @@ where
|
||||||
set_sticker_set_thumb, answer_shipping_query, answer_pre_checkout_query,
|
set_sticker_set_thumb, answer_shipping_query, answer_pre_checkout_query,
|
||||||
set_passport_data_errors, send_game, set_game_score, set_game_score_inline,
|
set_passport_data_errors, send_game, set_game_score, set_game_score_inline,
|
||||||
approve_chat_join_request, decline_chat_join_request,
|
approve_chat_join_request, decline_chat_join_request,
|
||||||
get_game_high_scores, get_updates_fault_tolerant => fid, ftyid
|
get_game_high_scores => fid, ftyid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,8 +138,7 @@ where
|
||||||
set_sticker_set_thumb, send_invoice, answer_shipping_query,
|
set_sticker_set_thumb, send_invoice, answer_shipping_query,
|
||||||
answer_pre_checkout_query, set_passport_data_errors, send_game,
|
answer_pre_checkout_query, set_passport_data_errors, send_game,
|
||||||
set_game_score, set_game_score_inline, get_game_high_scores,
|
set_game_score, set_game_score_inline, get_game_high_scores,
|
||||||
approve_chat_join_request, decline_chat_join_request,
|
approve_chat_join_request, decline_chat_join_request => fwd_inner, fty
|
||||||
get_updates_fault_tolerant => fwd_inner, fty
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1106,13 +1106,4 @@ impl Requester for Bot {
|
||||||
{
|
{
|
||||||
Self::UnpinAllChatMessages::new(self.clone(), payloads::UnpinAllChatMessages::new(chat_id))
|
Self::UnpinAllChatMessages::new(self.clone(), payloads::UnpinAllChatMessages::new(chat_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetUpdatesFaultTolerant = JsonRequest<payloads::GetUpdatesFaultTolerant>;
|
|
||||||
|
|
||||||
fn get_updates_fault_tolerant(&self) -> Self::GetUpdatesFaultTolerant {
|
|
||||||
Self::GetUpdatesFaultTolerant::new(
|
|
||||||
self.clone(),
|
|
||||||
payloads::GetUpdatesFaultTolerant(payloads::GetUpdates::new()),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1195,13 +1195,4 @@ macro_rules! requester_forward {
|
||||||
$body!(get_game_high_scores this (user_id: i64, target: T))
|
$body!(get_game_high_scores this (user_id: i64, target: T))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
(@method get_updates_fault_tolerant $body:ident $ty:ident) => {
|
|
||||||
type GetUpdatesFaultTolerant = $ty![GetUpdatesFaultTolerant];
|
|
||||||
|
|
||||||
fn get_updates_fault_tolerant(&self) -> Self::GetUpdatesFaultTolerant {
|
|
||||||
let this = self;
|
|
||||||
$body!(get_updates_fault_tolerant this ())
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,7 +213,3 @@ pub use unpin_chat_message::{UnpinChatMessage, UnpinChatMessageSetters};
|
||||||
pub use upload_sticker_file::{UploadStickerFile, UploadStickerFileSetters};
|
pub use upload_sticker_file::{UploadStickerFile, UploadStickerFileSetters};
|
||||||
|
|
||||||
// end of auto generated block
|
// end of auto generated block
|
||||||
|
|
||||||
mod get_updates_fault_tolerant;
|
|
||||||
|
|
||||||
pub use get_updates_fault_tolerant::GetUpdatesFaultTolerant;
|
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
use serde::Serialize;
|
|
||||||
|
|
||||||
use crate::{
|
|
||||||
payloads::GetUpdates,
|
|
||||||
requests::Payload,
|
|
||||||
types::{SemiparsedVec, Update},
|
|
||||||
};
|
|
||||||
|
|
||||||
/// The fault tolerant version of [`GetUpdates`].
|
|
||||||
#[derive(Debug, PartialEq, Eq, Hash, Default, Clone, Serialize)]
|
|
||||||
#[serde(transparent)]
|
|
||||||
pub struct GetUpdatesFaultTolerant(pub GetUpdates);
|
|
||||||
|
|
||||||
impl Payload for GetUpdatesFaultTolerant {
|
|
||||||
type Output = SemiparsedVec<Update>;
|
|
||||||
|
|
||||||
const NAME: &'static str = GetUpdates::NAME;
|
|
||||||
}
|
|
|
@ -856,11 +856,6 @@ pub trait Requester {
|
||||||
fn get_game_high_scores<T>(&self, user_id: i64, target: T) -> Self::GetGameHighScores
|
fn get_game_high_scores<T>(&self, user_id: i64, target: T) -> Self::GetGameHighScores
|
||||||
where
|
where
|
||||||
T: Into<TargetMessage>;
|
T: Into<TargetMessage>;
|
||||||
|
|
||||||
type GetUpdatesFaultTolerant: Request<Payload = GetUpdatesFaultTolerant, Err = Self::Err>;
|
|
||||||
|
|
||||||
/// For Telegram documentation see [`GetUpdatesFaultTolerant`].
|
|
||||||
fn get_updates_fault_tolerant(&self) -> Self::GetUpdatesFaultTolerant;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! fty {
|
macro_rules! fty {
|
||||||
|
@ -901,8 +896,7 @@ macro_rules! forward_all {
|
||||||
set_sticker_set_thumb, send_invoice, answer_shipping_query,
|
set_sticker_set_thumb, send_invoice, answer_shipping_query,
|
||||||
answer_pre_checkout_query, set_passport_data_errors, send_game,
|
answer_pre_checkout_query, set_passport_data_errors, send_game,
|
||||||
set_game_score, set_game_score_inline, get_game_high_scores,
|
set_game_score, set_game_score_inline, get_game_high_scores,
|
||||||
approve_chat_join_request, decline_chat_join_request,
|
approve_chat_join_request, decline_chat_join_request => fwd_deref, fty
|
||||||
get_updates_fault_tolerant => fwd_deref, fty
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -998,7 +992,6 @@ where
|
||||||
set_sticker_set_thumb, send_invoice, answer_shipping_query,
|
set_sticker_set_thumb, send_invoice, answer_shipping_query,
|
||||||
answer_pre_checkout_query, set_passport_data_errors, send_game,
|
answer_pre_checkout_query, set_passport_data_errors, send_game,
|
||||||
set_game_score, set_game_score_inline, get_game_high_scores,
|
set_game_score, set_game_score_inline, get_game_high_scores,
|
||||||
approve_chat_join_request, decline_chat_join_request,
|
approve_chat_join_request, decline_chat_join_request => fwd_either, fty_either
|
||||||
get_updates_fault_tolerant => fwd_either, fty_either
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,12 +214,11 @@ mod passport_data;
|
||||||
mod passport_element_error;
|
mod passport_element_error;
|
||||||
mod passport_file;
|
mod passport_file;
|
||||||
|
|
||||||
pub use non_telegram_types::{country_code::*, currency::*, semiparsed_vec::*, until_date::*};
|
pub use non_telegram_types::{country_code::*, currency::*, until_date::*};
|
||||||
mod non_telegram_types {
|
mod non_telegram_types {
|
||||||
pub(super) mod country_code;
|
pub(super) mod country_code;
|
||||||
pub(super) mod currency;
|
pub(super) mod currency;
|
||||||
pub(crate) mod mime;
|
pub(crate) mod mime;
|
||||||
pub(super) mod semiparsed_vec;
|
|
||||||
pub(super) mod until_date;
|
pub(super) mod until_date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
use serde::de::DeserializeOwned;
|
|
||||||
use serde_json::{from_value, Value};
|
|
||||||
|
|
||||||
/// A vector of possibly unparsed JSON objects.
|
|
||||||
///
|
|
||||||
/// Similar to `Vec<T>` but if it fails to deserialize element, it just saves
|
|
||||||
/// `Err((serde_json::Value, serde_json::Error))`.
|
|
||||||
#[derive(Debug, serde::Deserialize)]
|
|
||||||
#[serde(from = "Vec<serde_json::Value>")]
|
|
||||||
#[serde(bound = "T: DeserializeOwned")]
|
|
||||||
pub struct SemiparsedVec<T>(pub Vec<Result<T, (serde_json::Value, serde_json::Error)>>);
|
|
||||||
|
|
||||||
impl<T: DeserializeOwned> From<Vec<serde_json::Value>> for SemiparsedVec<T> {
|
|
||||||
fn from(vec: Vec<Value>) -> Self {
|
|
||||||
Self(
|
|
||||||
vec.into_iter()
|
|
||||||
.map(|val| from_value(val.clone()).map_err(|e| (val, e)))
|
|
||||||
.collect(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test() {
|
|
||||||
use crate::types::Update;
|
|
||||||
|
|
||||||
let x: SemiparsedVec<Update> = serde_json::from_str(
|
|
||||||
r#"[{
|
|
||||||
"update_id": 923808447,
|
|
||||||
"message": {
|
|
||||||
"message_id": 361678,
|
|
||||||
"from": {
|
|
||||||
"id": 218485655,
|
|
||||||
"is_bot": false,
|
|
||||||
"first_name": "вафель",
|
|
||||||
"last_name": "🧇",
|
|
||||||
"username": "WaffleLapkin",
|
|
||||||
"language_code": "en"
|
|
||||||
},
|
|
||||||
"chat": {
|
|
||||||
"id": 218485655,
|
|
||||||
"first_name": "вафель",
|
|
||||||
"last_name": "🧇",
|
|
||||||
"username": "WaffleLapkin",
|
|
||||||
"type": "private"
|
|
||||||
},
|
|
||||||
"date": 1595860067,
|
|
||||||
"text": "s"
|
|
||||||
}
|
|
||||||
}]"#,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert!(x.0.first().unwrap().is_ok())
|
|
||||||
}
|
|
Loading…
Reference in a new issue