use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ChatPermissions {
#[serde(skip_serializing_if = "Option::is_none")]
pub can_send_messages: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_send_audios: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_send_documents: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_send_photos: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_send_videos: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_send_video_notes: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_send_voice_notes: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_send_polls: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_send_other_messages: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_add_web_page_previews: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_edit_tag: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_change_info: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_invite_users: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_pin_messages: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub can_manage_topics: Option<bool>,
}
impl ChatPermissions {
#[must_use]
pub fn new() -> Self {
Self {
can_send_messages: None,
can_send_audios: None,
can_send_documents: None,
can_send_photos: None,
can_send_videos: None,
can_send_video_notes: None,
can_send_voice_notes: None,
can_send_polls: None,
can_send_other_messages: None,
can_add_web_page_previews: None,
can_edit_tag: None,
can_change_info: None,
can_invite_users: None,
can_pin_messages: None,
can_manage_topics: None,
}
}
#[must_use]
pub fn can_send_messages<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_send_messages = Some(val.into());
this
}
#[must_use]
pub fn can_send_messages_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_send_messages = val.map(Into::into);
this
}
#[must_use]
pub fn can_send_audios<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_send_audios = Some(val.into());
this
}
#[must_use]
pub fn can_send_audios_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_send_audios = val.map(Into::into);
this
}
#[must_use]
pub fn can_send_documents<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_send_documents = Some(val.into());
this
}
#[must_use]
pub fn can_send_documents_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_send_documents = val.map(Into::into);
this
}
#[must_use]
pub fn can_send_photos<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_send_photos = Some(val.into());
this
}
#[must_use]
pub fn can_send_photos_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_send_photos = val.map(Into::into);
this
}
#[must_use]
pub fn can_send_videos<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_send_videos = Some(val.into());
this
}
#[must_use]
pub fn can_send_videos_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_send_videos = val.map(Into::into);
this
}
#[must_use]
pub fn can_send_video_notes<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_send_video_notes = Some(val.into());
this
}
#[must_use]
pub fn can_send_video_notes_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_send_video_notes = val.map(Into::into);
this
}
#[must_use]
pub fn can_send_voice_notes<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_send_voice_notes = Some(val.into());
this
}
#[must_use]
pub fn can_send_voice_notes_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_send_voice_notes = val.map(Into::into);
this
}
#[must_use]
pub fn can_send_polls<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_send_polls = Some(val.into());
this
}
#[must_use]
pub fn can_send_polls_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_send_polls = val.map(Into::into);
this
}
#[must_use]
pub fn can_send_other_messages<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_send_other_messages = Some(val.into());
this
}
#[must_use]
pub fn can_send_other_messages_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_send_other_messages = val.map(Into::into);
this
}
#[must_use]
pub fn can_add_web_page_previews<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_add_web_page_previews = Some(val.into());
this
}
#[must_use]
pub fn can_add_web_page_previews_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_add_web_page_previews = val.map(Into::into);
this
}
#[must_use]
pub fn can_edit_tag<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_edit_tag = Some(val.into());
this
}
#[must_use]
pub fn can_edit_tag_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_edit_tag = val.map(Into::into);
this
}
#[must_use]
pub fn can_change_info<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_change_info = Some(val.into());
this
}
#[must_use]
pub fn can_change_info_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_change_info = val.map(Into::into);
this
}
#[must_use]
pub fn can_invite_users<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_invite_users = Some(val.into());
this
}
#[must_use]
pub fn can_invite_users_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_invite_users = val.map(Into::into);
this
}
#[must_use]
pub fn can_pin_messages<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_pin_messages = Some(val.into());
this
}
#[must_use]
pub fn can_pin_messages_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_pin_messages = val.map(Into::into);
this
}
#[must_use]
pub fn can_manage_topics<T: Into<bool>>(self, val: T) -> Self {
let mut this = self;
this.can_manage_topics = Some(val.into());
this
}
#[must_use]
pub fn can_manage_topics_option<T: Into<bool>>(self, val: Option<T>) -> Self {
let mut this = self;
this.can_manage_topics = val.map(Into::into);
this
}
}
impl Default for ChatPermissions {
fn default() -> Self {
Self::new()
}
}