Add GetUpdatesFaultTolerant

This commit is contained in:
Waffle 2021-02-27 01:07:57 +03:00
parent 7025de58f5
commit 7e43c4d321
10 changed files with 61 additions and 9 deletions

View file

@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [unreleased]
### Added
- `GetUpdatesFaultTolerant` - fault toletant version of `GetUpdates` ([#58][pr58]) (**BC**)
[pr58]: https://github.com/teloxide/teloxide-core/pull/58
### Fixed
- Fix typos in payloads ([#57][pr57]):

View file

@ -101,7 +101,8 @@ where
add_sticker_to_set, set_sticker_position_in_set, delete_sticker_from_set,
set_sticker_set_thumb, send_invoice, answer_shipping_query,
answer_pre_checkout_query, set_passport_data_errors, send_game,
set_game_score, set_game_score_inline, get_game_high_scores => f, fty
set_game_score, set_game_score_inline, get_game_high_scores,
get_updates_fault_tolerant => f, fty
}
}

View file

@ -118,7 +118,7 @@ where
add_sticker_to_set, set_sticker_position_in_set, delete_sticker_from_set,
set_sticker_set_thumb, send_invoice, answer_shipping_query,
answer_pre_checkout_query, set_passport_data_errors, send_game,
set_game_score, set_game_score_inline, get_game_high_scores => f, fty
set_game_score, set_game_score_inline, get_game_high_scores, get_updates_fault_tolerant => f, fty
}
}

View file

@ -112,7 +112,7 @@ impl<B: Requester> Requester for DefaultParseMode<B> {
add_sticker_to_set, set_sticker_position_in_set, delete_sticker_from_set,
set_sticker_set_thumb, send_invoice, answer_shipping_query,
answer_pre_checkout_query, set_passport_data_errors, send_game, set_game_score,
set_game_score_inline, get_game_high_scores => fid, fty
set_game_score_inline, get_game_high_scores, get_updates_fault_tolerant => fid, fty
}
}

View file

@ -469,7 +469,7 @@ where
add_sticker_to_set, set_sticker_position_in_set, delete_sticker_from_set,
set_sticker_set_thumb, answer_shipping_query, answer_pre_checkout_query,
set_passport_data_errors, send_game, set_game_score, set_game_score_inline,
get_game_high_scores => fid, ftyid
get_game_high_scores, get_updates_fault_tolerant => fid, ftyid
}
}

View file

@ -970,4 +970,13 @@ impl Requester for Bot {
payloads::GetGameHighScores::new(user_id, target),
)
}
type GetUpdatesFaultTolerant = JsonRequest<payloads::GetUpdatesFaultTolerant>;
fn get_updates_fault_tolerant(&self) -> Self::GetUpdatesFaultTolerant {
Self::GetUpdatesFaultTolerant::new(
self.clone(),
payloads::GetUpdatesFaultTolerant(payloads::GetUpdates::new()),
)
}
}

View file

@ -393,7 +393,7 @@ macro_rules! impl_payload {
}
#[macro_use]
// This macro is auto generated by `cg` <https://github.com/teloxide/cg> (8ee7ef2).
// This macro is auto generated by `cg` <https://github.com/teloxide/cg> (24572cd + local changes).
// **DO NOT EDIT THIS MACRO**,
// edit `cg` instead.
macro_rules! requester_forward {
@ -403,8 +403,6 @@ macro_rules! requester_forward {
requester_forward!(@method $rest $body $ty);
)*
};
(@method get_updates $body:ident $ty:ident) => {
type GetUpdates = $ty![GetUpdates];
@ -1046,6 +1044,14 @@ macro_rules! requester_forward {
$body!(get_game_high_scores this (user_id: u32, 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 ())
}
};
}
#[macro_use]

View file

@ -178,3 +178,9 @@ pub use stop_poll::{StopPoll, StopPollSetters};
pub use unban_chat_member::{UnbanChatMember, UnbanChatMemberSetters};
pub use unpin_chat_message::{UnpinChatMessage, UnpinChatMessageSetters};
pub use upload_sticker_file::{UploadStickerFile, UploadStickerFileSetters};
// end of auto generated block
mod get_updates_fault_tolerant;
pub use get_updates_fault_tolerant::GetUpdatesFaultTolerant;

View file

@ -0,0 +1,18 @@
use serde::Serialize;
use crate::{
payloads::GetUpdates,
requests::Payload,
types::{NonStrictVec, Update},
};
/// Fault tollerant version of [`GetUpdates`].
#[derive(Debug, PartialEq, Eq, Hash, Default, Clone, Serialize)]
#[serde(transparent)]
pub struct GetUpdatesFaultTolerant(pub GetUpdates);
impl Payload for GetUpdatesFaultTolerant {
type Output = NonStrictVec<Update>;
const NAME: &'static str = GetUpdates::NAME;
}

View file

@ -53,7 +53,7 @@ pub trait Requester {
/// Error type returned by all requests.
type Err: std::error::Error + Send;
// This block is auto generated by `cg` <https://github.com/teloxide/cg> (8ee7ef2).
// This block is auto generated by `cg` <https://github.com/teloxide/cg> (dec2d73).
// **DO NOT EDIT THIS BLOCK**,
// edit `cg` instead.
@ -749,6 +749,11 @@ pub trait Requester {
fn get_game_high_scores<T>(&self, user_id: u32, target: T) -> Self::GetGameHighScores
where
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 {
@ -786,7 +791,8 @@ macro_rules! forward_all {
add_sticker_to_set, set_sticker_position_in_set, delete_sticker_from_set,
set_sticker_set_thumb, send_invoice, answer_shipping_query,
answer_pre_checkout_query, set_passport_data_errors, send_game,
set_game_score, set_game_score_inline, get_game_high_scores => fwd_deref, fty
set_game_score, set_game_score_inline, get_game_high_scores,
get_updates_fault_tolerant => fwd_deref, fty
}
};
}