Skip to main content

grammers_client/update/
message.rs

1// Copyright 2020 - developers of the `grammers` project.
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9use std::ops::{Deref, DerefMut};
10
11use grammers_session::updates::State;
12use grammers_tl_types as tl;
13
14/// Update that all receive whenever a message is received or edited.
15///
16/// For bots to receive this update, they must either be an administrator
17/// or have disabled the privacy mode via [@BotFather](https://t.me/BotFather).
18#[derive(Debug, Clone)]
19pub struct Message {
20    pub(crate) msg: crate::message::Message,
21    pub raw: tl::enums::Update,
22    pub state: State,
23}
24
25impl Deref for Message {
26    type Target = crate::message::Message;
27
28    fn deref(&self) -> &Self::Target {
29        &self.msg
30    }
31}
32
33impl DerefMut for Message {
34    fn deref_mut(&mut self) -> &mut Self::Target {
35        &mut self.msg
36    }
37}