pub struct Update {
pub id: UpdateId,
pub kind: UpdateKind,
}Expand description
This object represents an incoming update.
Fields§
§id: UpdateIdThe update‘s unique identifier. Update identifiers start from a certain positive number and increase sequentially. This ID becomes especially handy if you’re using webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order. If there are no new updates for at least a week, then identifier of the next update will be chosen randomly instead of sequentially.
kind: UpdateKindImplementations§
Source§impl Update
impl Update
Sourcepub fn from(&self) -> Option<&User>
pub fn from(&self) -> Option<&User>
Returns the user that performed the action that caused this update, if known.
This is generally the from field (except for PollAnswer where it’s
user and Poll with Error which don’t have such field at all).
Sourcepub fn mentioned_users(&self) -> impl Iterator<Item = &User>
pub fn mentioned_users(&self) -> impl Iterator<Item = &User>
Returns all users that are “contained” in this Update structure.
This might be useful to track information about users.
Note that this function may return quite a few users as it scans replies, pinned messages, message entities, “via bot” fields and more. Also note that this function can return duplicate users.
Sourcepub fn chat(&self) -> Option<&Chat>
pub fn chat(&self) -> Option<&Chat>
Returns the chat in which is update has happened, if any.
Examples found in repository?
20async fn report_error(error: teloxide::RequestError, deps: DependencyMap) {
21 log::error!("Could not handle update: {error}");
22 let (Some(bot), Some(update)) = (deps.try_get::<Bot>(), deps.try_get::<Update>()) else {
23 return;
24 };
25 if let Some(chat) = update.chat() {
26 bot.send_message("Something went wrong. Please try again later.")
27 .chat_id(chat.id)
28 .await
29 .log_on_error()
30 .await;
31 }
32}Trait Implementations§
Source§impl<'de> Deserialize<'de> for Update
impl<'de> Deserialize<'de> for Update
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Update, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Update, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl GetChatId for Update
impl GetChatId for Update
fn chat_id(&self) -> Option<ChatId>
Source§fn dialogue_key(&self) -> Option<DialogueKey>
fn dialogue_key(&self) -> Option<DialogueKey>
Source§impl Serialize for Update
impl Serialize for Update
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Update
Source§impl<Out> UpdateFilterExt<Out> for Update
impl<Out> UpdateFilterExt<Out> for Update
Source§fn filter_message() -> Handler<'static, Out, DpHandlerDescription>
fn filter_message() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::Message objects.Source§fn filter_guest_message() -> Handler<'static, Out, DpHandlerDescription>
fn filter_guest_message() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::GuestMessage objects.Source§fn filter_edited_message() -> Handler<'static, Out, DpHandlerDescription>
fn filter_edited_message() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::EditedMessage objects.Source§fn filter_channel_post() -> Handler<'static, Out, DpHandlerDescription>
fn filter_channel_post() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::ChannelPost objects.Source§fn filter_edited_channel_post() -> Handler<'static, Out, DpHandlerDescription>
fn filter_edited_channel_post() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::EditedChannelPost objects.Source§fn filter_business_connection() -> Handler<'static, Out, DpHandlerDescription>
fn filter_business_connection() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::BusinessConnection objects.Source§fn filter_business_message() -> Handler<'static, Out, DpHandlerDescription>
fn filter_business_message() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::BusinessMessage objects.Source§fn filter_edited_business_message() -> Handler<'static, Out, DpHandlerDescription>
fn filter_edited_business_message() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::EditedBusinessMessage objects.Source§fn filter_deleted_business_messages() -> Handler<'static, Out, DpHandlerDescription>
fn filter_deleted_business_messages() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::DeletedBusinessMessages objects.Source§fn filter_message_reaction_updated() -> Handler<'static, Out, DpHandlerDescription>
fn filter_message_reaction_updated() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::MessageReaction objects.Source§fn filter_message_reaction_count_updated() -> Handler<'static, Out, DpHandlerDescription>
fn filter_message_reaction_count_updated() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::MessageReactionCount objects.Source§fn filter_inline_query() -> Handler<'static, Out, DpHandlerDescription>
fn filter_inline_query() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::InlineQuery objects.Source§fn filter_chosen_inline_result() -> Handler<'static, Out, DpHandlerDescription>
fn filter_chosen_inline_result() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::ChosenInlineResult objects.Source§fn filter_callback_query() -> Handler<'static, Out, DpHandlerDescription>
fn filter_callback_query() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::CallbackQuery objects.Source§fn filter_shipping_query() -> Handler<'static, Out, DpHandlerDescription>
fn filter_shipping_query() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::ShippingQuery objects.Source§fn filter_pre_checkout_query() -> Handler<'static, Out, DpHandlerDescription>
fn filter_pre_checkout_query() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::PreCheckoutQuery objects.Source§fn filter_purchased_paid_media() -> Handler<'static, Out, DpHandlerDescription>
fn filter_purchased_paid_media() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::PurchasedPaidMedia objects.Source§fn filter_poll() -> Handler<'static, Out, DpHandlerDescription>
fn filter_poll() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::Poll objects.Source§fn filter_poll_answer() -> Handler<'static, Out, DpHandlerDescription>
fn filter_poll_answer() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::PollAnswer objects.Source§fn filter_my_chat_member() -> Handler<'static, Out, DpHandlerDescription>
fn filter_my_chat_member() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::MyChatMember objects.Source§fn filter_chat_member() -> Handler<'static, Out, DpHandlerDescription>
fn filter_chat_member() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::ChatMember objects.Source§fn filter_chat_join_request() -> Handler<'static, Out, DpHandlerDescription>
fn filter_chat_join_request() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::ChatJoinRequest objects.Source§fn filter_chat_boost() -> Handler<'static, Out, DpHandlerDescription>
fn filter_chat_boost() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::ChatBoost objects.Source§fn filter_removed_chat_boost() -> Handler<'static, Out, DpHandlerDescription>
fn filter_removed_chat_boost() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::RemovedChatBoost objects.Source§fn filter_managed_bot_updated() -> Handler<'static, Out, DpHandlerDescription>
fn filter_managed_bot_updated() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::ManagedBot objects.Source§fn filter_stopped_message_generation() -> Handler<'static, Out, DpHandlerDescription>
fn filter_stopped_message_generation() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::StoppedMessageGeneration objects.Source§fn filter_widget_query() -> Handler<'static, Out, DpHandlerDescription>
fn filter_widget_query() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::WidgetQuery objects.UpdateKind::SharedWidgetQuery objects.Source§fn filter_subscription() -> Handler<'static, Out, DpHandlerDescription>
fn filter_subscription() -> Handler<'static, Out, DpHandlerDescription>
UpdateKind::Subscription objects.Auto Trait Implementations§
impl Forget for Update
impl Freeze for Updatewhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
NonZero<i32>: Freeze,
Utc: Freeze,
*const Message is !null: Freeze,
PhantomData<Message>: Freeze,
&'static str: Freeze,
PhantomData<(Indexed, Indexed)>: Freeze,
PhantomData<PaidMedia>: Freeze,
PhantomData<PhotoSize>: Freeze,
PhantomData<MessageEntity>: Freeze,
PhantomData<PollOption>: Freeze,
PhantomData<String>: Freeze,
PhantomData<VideoQuality>: Freeze,
PhantomData<ChecklistTask>: Freeze,
PhantomData<Chat>: Freeze,
PhantomData<CountryCode>: Freeze,
PhantomData<User>: Freeze,
PhantomData<RichText>: Freeze,
*const MediaPoll is !null: Freeze,
PhantomData<MediaPoll>: Freeze,
PhantomData<RichBlock>: Freeze,
PhantomData<Vec<InlineKeyboardButton>>: Freeze,
*const MaybeInaccessibleMessage is !null: Freeze,
PhantomData<MaybeInaccessibleMessage>: Freeze,
PhantomData<SharedUser>: Freeze,
PhantomData<EncryptedPassportElement>: Freeze,
PhantomData<Rgb>: Freeze,
PhantomData<ChecklistTaskId>: Freeze,
PhantomData<Value>: Freeze,
*const LeafNode<String, Value> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(String, Value)>>: Freeze,
PhantomData<MessageId>: Freeze,
PhantomData<ReactionType>: Freeze,
PhantomData<ReactionCount>: Freeze,
PhantomData<TonWalletCardSticker>: Freeze,
impl Move for Update
impl RefUnwindSafe for Update
impl Send for Updatewhere
RawVecInner: Send,
NonZero<i32>: Send,
Utc: Send,
BoxRaw<Message>: Send,
&'static str: Send,
BoxRaw<PaidMediaVideo>: Send,
BoxRaw<RichTextKind>: Send,
BoxRaw<MediaPoll>: Send,
NodeRef<Owned, String, Value, LeafOrInternal>: Send,
BoxRaw<(String, Value)>: Send,
BoxRaw<MaybeInaccessibleMessage>: Send,
impl Sync for Update
impl Unpin for Update
impl UnsafeUnpin for Updatewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
NonZeroI32Inner: UnsafeUnpin,
Utc: UnsafeUnpin,
*const Message is !null: UnsafeUnpin,
PhantomData<Message>: UnsafeUnpin,
&'static str: UnsafeUnpin,
PhantomData<(Indexed, Indexed)>: UnsafeUnpin,
PhantomData<PaidMedia>: UnsafeUnpin,
PhantomData<PhotoSize>: UnsafeUnpin,
PhantomData<MessageEntity>: UnsafeUnpin,
PhantomData<PollOption>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
PhantomData<VideoQuality>: UnsafeUnpin,
PhantomData<ChecklistTask>: UnsafeUnpin,
PhantomData<Chat>: UnsafeUnpin,
PhantomData<CountryCode>: UnsafeUnpin,
PhantomData<User>: UnsafeUnpin,
PhantomData<RichText>: UnsafeUnpin,
*const MediaPoll is !null: UnsafeUnpin,
PhantomData<MediaPoll>: UnsafeUnpin,
PhantomData<RichBlock>: UnsafeUnpin,
PhantomData<Vec<InlineKeyboardButton>>: UnsafeUnpin,
*const MaybeInaccessibleMessage is !null: UnsafeUnpin,
PhantomData<MaybeInaccessibleMessage>: UnsafeUnpin,
PhantomData<SharedUser>: UnsafeUnpin,
PhantomData<EncryptedPassportElement>: UnsafeUnpin,
PhantomData<Rgb>: UnsafeUnpin,
PhantomData<ChecklistTaskId>: UnsafeUnpin,
PhantomData<Value>: UnsafeUnpin,
*const LeafNode<String, Value> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(String, Value)>>: UnsafeUnpin,
PhantomData<MessageId>: UnsafeUnpin,
PhantomData<ReactionType>: UnsafeUnpin,
PhantomData<ReactionCount>: UnsafeUnpin,
PhantomData<TonWalletCardSticker>: UnsafeUnpin,
impl UnwindSafe for Updatewhere
RawVecInner: UnwindSafe,
NonZero<i32>: UnwindSafe,
Utc: UnwindSafe,
BoxRaw<Message>: UnwindSafe,
&'static str: UnwindSafe,
BoxRaw<PaidMediaVideo>: UnwindSafe,
BoxRaw<RichTextKind>: UnwindSafe,
BoxRaw<MediaPoll>: UnwindSafe,
BTreeMap<String, Value>: UnwindSafe,
BoxRaw<MaybeInaccessibleMessage>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Erasable for T
impl<T> Erasable for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more