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 Message {
26 pub fn into_inner(self) -> crate::message::Message {
27 self.msg
28 }
29}
30
31impl Deref for Message {
32 type Target = crate::message::Message;
33
34 fn deref(&self) -> &Self::Target {
35 &self.msg
36 }
37}
38
39impl DerefMut for Message {
40 fn deref_mut(&mut self) -> &mut Self::Target {
41 &mut self.msg
42 }
43}