pub struct ChatPermissions(/* private fields */);Expand description
Describes actions that a non-administrator user is allowed to take in a chat.
§Examples
use teloxide_core::types::ChatPermissions;
// No permissions, nothing is allowed
let _ = ChatPermissions::empty();
// All permissions, everything is allowed
let _ = ChatPermissions::all();
// One particular permission
let permissions_v0 = ChatPermissions::INVITE_USERS;
// Check what is permitted
assert!(permissions_v0.contains(ChatPermissions::INVITE_USERS));
assert!(!permissions_v0.contains(ChatPermissions::SEND_MESSAGES));
// Union, add permissions
let permissions_v1 = permissions_v0 | ChatPermissions::SEND_VIDEOS;
assert!(permissions_v1.contains(ChatPermissions::INVITE_USERS));
assert!(permissions_v1.contains(ChatPermissions::SEND_VIDEOS));
// Difference, remove permissions
let permissions_v2 = permissions_v1 - ChatPermissions::SEND_VIDEOS;
assert!(!permissions_v2.contains(ChatPermissions::SEND_VIDEOS));Implementations§
Source§impl ChatPermissions
impl ChatPermissions
Sourcepub const SEND_MESSAGES: ChatPermissions
pub const SEND_MESSAGES: ChatPermissions
Set if the user is allowed to send text messages, contacts, giveaways, giveaway winners, invoices, locations and venues
Sourcepub const SEND_POLLS: ChatPermissions
pub const SEND_POLLS: ChatPermissions
Set if the user is allowed to send polls
Sourcepub const SEND_OTHER_MESSAGES: ChatPermissions
pub const SEND_OTHER_MESSAGES: ChatPermissions
Set if the user is allowed to send animations, games, stickers, widgets and use inline bots.
Sourcepub const ADD_WEB_PAGE_PREVIEWS: ChatPermissions
pub const ADD_WEB_PAGE_PREVIEWS: ChatPermissions
Set if the user is allowed to add web page previews to their messages.
Sourcepub const CHANGE_INFO: ChatPermissions
pub const CHANGE_INFO: ChatPermissions
Set if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups.
Sourcepub const INVITE_USERS: ChatPermissions
pub const INVITE_USERS: ChatPermissions
Set if the user is allowed to invite new users to the chat.
Sourcepub const PIN_MESSAGES: ChatPermissions
pub const PIN_MESSAGES: ChatPermissions
Set if the user is allowed to pin messages. Ignored in public supergroups.
Sourcepub const MANAGE_TOPICS: ChatPermissions
pub const MANAGE_TOPICS: ChatPermissions
Set if the user is allowed to create, rename, close, and reopen forum topics.
Sourcepub const SEND_AUDIOS: ChatPermissions
pub const SEND_AUDIOS: ChatPermissions
Set if the user is allowed to send audios.
Sourcepub const SEND_DOCUMENTS: ChatPermissions
pub const SEND_DOCUMENTS: ChatPermissions
Set if the user is allowed to send documents.
Sourcepub const SEND_PHOTOS: ChatPermissions
pub const SEND_PHOTOS: ChatPermissions
Set if the user is allowed to send photos.
Sourcepub const SEND_VIDEOS: ChatPermissions
pub const SEND_VIDEOS: ChatPermissions
Set if the user is allowed to send videos.
Sourcepub const SEND_VIDEO_NOTES: ChatPermissions
pub const SEND_VIDEO_NOTES: ChatPermissions
Set if the user is allowed to send video notes.
Sourcepub const SEND_VOICE_NOTES: ChatPermissions
pub const SEND_VOICE_NOTES: ChatPermissions
Set if the user is allowed to send voice notes. implies
SEND_MESSAGES.
Sourcepub const SEND_MEDIA_MESSAGES: ChatPermissions
pub const SEND_MEDIA_MESSAGES: ChatPermissions
Set if the user is allowed to send audios, documents,
photos, videos, video notes and voice notes, implies
SEND_AUDIOS, SEND_DOCUMENTS, SEND_PHOTOS,
SEND_VIDEOS, SEND_VIDEO_NOTES and SEND_VOICE_NOTES.
Note: this is not a separate permission on it’s own, this is just a alias for all the permissions mentioned.
Sourcepub const EDIT_TAG: ChatPermissions
pub const EDIT_TAG: ChatPermissions
Set if the user is allowed to edit their own member tag.
Sourcepub const REACT_TO_MESSAGES: ChatPermissions
pub const REACT_TO_MESSAGES: ChatPermissions
Set if the user is allowed to react to messages.
Source§impl ChatPermissions
impl ChatPermissions
Sourcepub const fn empty() -> ChatPermissions
pub const fn empty() -> ChatPermissions
Get a flags value with all bits unset.
Examples found in repository?
114async fn mute_user(bot: Bot, msg: Message, time: Duration) -> ResponseResult<()> {
115 match msg.reply_to_message() {
116 Some(replied) => {
117 bot.restrict_chat_member(
118 msg.chat.id,
119 replied.from.as_ref().expect("Must be MessageKind::Common").id,
120 ChatPermissions::empty(),
121 )
122 .until_date(msg.date + time)
123 .await?;
124 }
125 None => {
126 bot.send_message("Use this command in a reply to another message!")
127 .chat_id(msg.chat.id)
128 .await?;
129 }
130 }
131 Ok(())
132}Sourcepub const fn all() -> ChatPermissions
pub const fn all() -> ChatPermissions
Get a flags value with all known bits set.
Sourcepub const fn bits(&self) -> u16
pub const fn bits(&self) -> u16
Get the underlying bits value.
The returned value is exactly the bits set in this flags value.
Sourcepub const fn from_bits(bits: u16) -> Option<ChatPermissions>
pub const fn from_bits(bits: u16) -> Option<ChatPermissions>
Convert from a bits value.
This method will return None if any unknown bits are set.
Sourcepub const fn from_bits_truncate(bits: u16) -> ChatPermissions
pub const fn from_bits_truncate(bits: u16) -> ChatPermissions
Convert from a bits value, unsetting any unknown bits.
Sourcepub const fn from_bits_retain(bits: u16) -> ChatPermissions
pub const fn from_bits_retain(bits: u16) -> ChatPermissions
Convert from a bits value exactly.
Sourcepub fn from_name(name: &str) -> Option<ChatPermissions>
pub fn from_name(name: &str) -> Option<ChatPermissions>
Get a flags value with the bits of a flag with the given name set.
This method will return None if name is empty or doesn’t
correspond to any named flag.
Sourcepub const fn intersects(&self, other: ChatPermissions) -> bool
pub const fn intersects(&self, other: ChatPermissions) -> bool
Whether any set bits in other are also set in self.
Sourcepub const fn contains(&self, other: ChatPermissions) -> bool
pub const fn contains(&self, other: ChatPermissions) -> bool
Whether all set bits in other are also set in self.
Sourcepub fn insert(&mut self, other: ChatPermissions)
pub fn insert(&mut self, other: ChatPermissions)
The bitwise or (|) of the bits in self and other.
Sourcepub fn remove(&mut self, other: ChatPermissions)
pub fn remove(&mut self, other: ChatPermissions)
The intersection of self with the complement of other (&!).
This method is not equivalent to self & !other when other has unknown bits set.
remove won’t truncate other, but the ! operator will.
Sourcepub fn toggle(&mut self, other: ChatPermissions)
pub fn toggle(&mut self, other: ChatPermissions)
The bitwise exclusive-or (^) of the bits in self and other.
Sourcepub fn set(&mut self, other: ChatPermissions, value: bool)
pub fn set(&mut self, other: ChatPermissions, value: bool)
Call insert when value is true or remove when value is false.
Sourcepub const fn intersection(self, other: ChatPermissions) -> ChatPermissions
pub const fn intersection(self, other: ChatPermissions) -> ChatPermissions
The bitwise and (&) of the bits in self and other.
Sourcepub const fn union(self, other: ChatPermissions) -> ChatPermissions
pub const fn union(self, other: ChatPermissions) -> ChatPermissions
The bitwise or (|) of the bits in self and other.
Sourcepub const fn difference(self, other: ChatPermissions) -> ChatPermissions
pub const fn difference(self, other: ChatPermissions) -> ChatPermissions
The intersection of self with the complement of other (&!).
This method is not equivalent to self & !other when other has unknown bits set.
difference won’t truncate other, but the ! operator will.
Sourcepub const fn symmetric_difference(
self,
other: ChatPermissions,
) -> ChatPermissions
pub const fn symmetric_difference( self, other: ChatPermissions, ) -> ChatPermissions
The bitwise exclusive-or (^) of the bits in self and other.
Sourcepub const fn complement(self) -> ChatPermissions
pub const fn complement(self) -> ChatPermissions
The bitwise negation (!) of the bits in self, truncating the result.
Source§impl ChatPermissions
impl ChatPermissions
Sourcepub const fn iter(&self) -> Iter<ChatPermissions> ⓘ
pub const fn iter(&self) -> Iter<ChatPermissions> ⓘ
Yield a set of contained flags values.
Each yielded flags value will correspond to a defined named flag. Any unknown bits will be yielded together as a final flags value.
Sourcepub const fn iter_names(&self) -> IterNames<ChatPermissions> ⓘ
pub const fn iter_names(&self) -> IterNames<ChatPermissions> ⓘ
Yield a set of contained named flags values.
This method is like iter, except only yields bits in contained named flags.
Any unknown bits, or bits not corresponding to a contained flag will not be yielded.
Source§impl ChatPermissions
impl ChatPermissions
Sourcepub fn can_send_messages(&self) -> bool
pub fn can_send_messages(&self) -> bool
Checks for SEND_MESSAGES permission.
Sourcepub fn can_send_audios(&self) -> bool
pub fn can_send_audios(&self) -> bool
Checks for SEND_AUDIOS permission.
Sourcepub fn can_send_documents(&self) -> bool
pub fn can_send_documents(&self) -> bool
Checks for SEND_DOCUMENTS permission.
Sourcepub fn can_send_photos(&self) -> bool
pub fn can_send_photos(&self) -> bool
Checks for SEND_PHOTOS permission.
Sourcepub fn can_send_videos(&self) -> bool
pub fn can_send_videos(&self) -> bool
Checks for SEND_VIDEOS permission.
Sourcepub fn can_send_video_notes(&self) -> bool
pub fn can_send_video_notes(&self) -> bool
Checks for SEND_VIDEO_NOTES permission.
Sourcepub fn can_send_voice_notes(&self) -> bool
pub fn can_send_voice_notes(&self) -> bool
Checks for SEND_VOICE_NOTES permission.
Sourcepub fn can_send_media_messages(&self) -> bool
pub fn can_send_media_messages(&self) -> bool
Checks for SEND_MEDIA_MESSAGES permission.
Sourcepub fn can_send_polls(&self) -> bool
pub fn can_send_polls(&self) -> bool
Checks for SEND_POLLS permission.
Sourcepub fn can_send_other_messages(&self) -> bool
pub fn can_send_other_messages(&self) -> bool
Checks for SEND_OTHER_MESSAGES permission.
Sourcepub fn can_add_web_page_previews(&self) -> bool
pub fn can_add_web_page_previews(&self) -> bool
Checks for ADD_WEB_PAGE_PREVIEWS permission.
Sourcepub fn can_change_info(&self) -> bool
pub fn can_change_info(&self) -> bool
Checks for CHANGE_INFO permission.
Sourcepub fn can_invite_users(&self) -> bool
pub fn can_invite_users(&self) -> bool
Checks for INVITE_USERS permission.
Sourcepub fn can_pin_messages(&self) -> bool
pub fn can_pin_messages(&self) -> bool
Checks for PIN_MESSAGES permission.
Sourcepub fn can_manage_topics(&self) -> bool
pub fn can_manage_topics(&self) -> bool
Checks for MANAGE_TOPICS permission.
Sourcepub fn can_edit_tag(&self) -> bool
pub fn can_edit_tag(&self) -> bool
Checks for EDIT_TAG permission.
Sourcepub fn can_react_to_messages(&self) -> bool
pub fn can_react_to_messages(&self) -> bool
Checks for REACT_TO_MESSAGES permission.
Trait Implementations§
Source§impl Binary for ChatPermissions
impl Binary for ChatPermissions
Source§impl BitAnd for ChatPermissions
impl BitAnd for ChatPermissions
Source§fn bitand(self, other: ChatPermissions) -> ChatPermissions
fn bitand(self, other: ChatPermissions) -> ChatPermissions
The bitwise and (&) of the bits in self and other.
Source§type Output = ChatPermissions
type Output = ChatPermissions
& operator.Source§impl BitAndAssign for ChatPermissions
impl BitAndAssign for ChatPermissions
Source§fn bitand_assign(&mut self, other: ChatPermissions)
fn bitand_assign(&mut self, other: ChatPermissions)
The bitwise and (&) of the bits in self and other.
Source§impl BitOr for ChatPermissions
impl BitOr for ChatPermissions
Source§fn bitor(self, other: ChatPermissions) -> ChatPermissions
fn bitor(self, other: ChatPermissions) -> ChatPermissions
The bitwise or (|) of the bits in self and other.
Source§type Output = ChatPermissions
type Output = ChatPermissions
| operator.Source§impl BitOrAssign for ChatPermissions
impl BitOrAssign for ChatPermissions
Source§fn bitor_assign(&mut self, other: ChatPermissions)
fn bitor_assign(&mut self, other: ChatPermissions)
The bitwise or (|) of the bits in self and other.
Source§impl BitXor for ChatPermissions
impl BitXor for ChatPermissions
Source§fn bitxor(self, other: ChatPermissions) -> ChatPermissions
fn bitxor(self, other: ChatPermissions) -> ChatPermissions
The bitwise exclusive-or (^) of the bits in self and other.
Source§type Output = ChatPermissions
type Output = ChatPermissions
^ operator.Source§impl BitXorAssign for ChatPermissions
impl BitXorAssign for ChatPermissions
Source§fn bitxor_assign(&mut self, other: ChatPermissions)
fn bitxor_assign(&mut self, other: ChatPermissions)
The bitwise exclusive-or (^) of the bits in self and other.
Source§impl Clone for ChatPermissions
impl Clone for ChatPermissions
Source§fn clone(&self) -> ChatPermissions
fn clone(&self) -> ChatPermissions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ChatPermissions
impl Debug for ChatPermissions
Source§impl<'de> Deserialize<'de> for ChatPermissions
impl<'de> Deserialize<'de> for ChatPermissions
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ChatPermissions, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ChatPermissions, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for ChatPermissions
Source§impl Extend<ChatPermissions> for ChatPermissions
impl Extend<ChatPermissions> for ChatPermissions
Source§fn extend<T>(&mut self, iterator: T)where
T: IntoIterator<Item = ChatPermissions>,
fn extend<T>(&mut self, iterator: T)where
T: IntoIterator<Item = ChatPermissions>,
The bitwise or (|) of the bits in each flags value.
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl Flags for ChatPermissions
impl Flags for ChatPermissions
Source§const FLAGS: &'static [Flag<ChatPermissions>]
const FLAGS: &'static [Flag<ChatPermissions>]
Source§fn from_bits_retain(bits: u16) -> ChatPermissions
fn from_bits_retain(bits: u16) -> ChatPermissions
Source§fn all_named() -> ChatPermissions
fn all_named() -> ChatPermissions
Source§fn known_bits(&self) -> Self::Bits
fn known_bits(&self) -> Self::Bits
Source§fn unknown_bits(&self) -> Self::Bits
fn unknown_bits(&self) -> Self::Bits
Source§fn contains_unknown_bits(&self) -> bool
fn contains_unknown_bits(&self) -> bool
true if any unknown bits are set.Source§fn from_bits_truncate(bits: Self::Bits) -> Self
fn from_bits_truncate(bits: Self::Bits) -> Self
Source§fn from_name(name: &str) -> Option<Self>
fn from_name(name: &str) -> Option<Self>
Source§fn iter_names(&self) -> IterNames<Self> ⓘ
fn iter_names(&self) -> IterNames<Self> ⓘ
Source§fn iter_defined_names() -> IterDefinedNames<Self> ⓘ
fn iter_defined_names() -> IterDefinedNames<Self> ⓘ
Self::FLAGS.Source§fn iter_equal_names(&self) -> IterEqualNames<Self> ⓘ
fn iter_equal_names(&self) -> IterEqualNames<Self> ⓘ
Source§fn intersects(&self, other: Self) -> boolwhere
Self: Sized,
fn intersects(&self, other: Self) -> boolwhere
Self: Sized,
other are also set in self.Source§fn contains(&self, other: Self) -> boolwhere
Self: Sized,
fn contains(&self, other: Self) -> boolwhere
Self: Sized,
other are also set in self.Source§fn insert(&mut self, other: Self)where
Self: Sized,
fn insert(&mut self, other: Self)where
Self: Sized,
|) of the bits in self and other.Source§fn toggle(&mut self, other: Self)where
Self: Sized,
fn toggle(&mut self, other: Self)where
Self: Sized,
^) of the bits in self and other.Source§fn intersection(self, other: Self) -> Self
fn intersection(self, other: Self) -> Self
&) of the bits in self and other.Source§fn difference(self, other: Self) -> Self
fn difference(self, other: Self) -> Self
Source§fn symmetric_difference(self, other: Self) -> Self
fn symmetric_difference(self, other: Self) -> Self
^) of the bits in self and other.Source§fn complement(self) -> Self
fn complement(self) -> Self
!) of the bits in self, truncating the result.Source§impl From<ChatPermissionsRaw> for ChatPermissions
impl From<ChatPermissionsRaw> for ChatPermissions
Source§fn from(_: ChatPermissionsRaw) -> ChatPermissions
fn from(_: ChatPermissionsRaw) -> ChatPermissions
Source§impl FromIterator<ChatPermissions> for ChatPermissions
impl FromIterator<ChatPermissions> for ChatPermissions
Source§fn from_iter<T>(iterator: T) -> ChatPermissionswhere
T: IntoIterator<Item = ChatPermissions>,
fn from_iter<T>(iterator: T) -> ChatPermissionswhere
T: IntoIterator<Item = ChatPermissions>,
The bitwise or (|) of the bits in each flags value.
Source§impl Hash for ChatPermissions
impl Hash for ChatPermissions
Source§impl IntoIterator for ChatPermissions
impl IntoIterator for ChatPermissions
Source§type Item = ChatPermissions
type Item = ChatPermissions
Source§type IntoIter = Iter<ChatPermissions>
type IntoIter = Iter<ChatPermissions>
Source§fn into_iter(self) -> <ChatPermissions as IntoIterator>::IntoIter
fn into_iter(self) -> <ChatPermissions as IntoIterator>::IntoIter
Source§impl LowerHex for ChatPermissions
impl LowerHex for ChatPermissions
Source§impl Not for ChatPermissions
impl Not for ChatPermissions
Source§fn not(self) -> ChatPermissions
fn not(self) -> ChatPermissions
The bitwise negation (!) of the bits in self, truncating the result.
Source§type Output = ChatPermissions
type Output = ChatPermissions
! operator.Source§impl Octal for ChatPermissions
impl Octal for ChatPermissions
Source§impl PartialEq for ChatPermissions
impl PartialEq for ChatPermissions
Source§impl Serialize for ChatPermissions
impl Serialize for ChatPermissions
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 ChatPermissions
Source§impl Sub for ChatPermissions
impl Sub for ChatPermissions
Source§fn sub(self, other: ChatPermissions) -> ChatPermissions
fn sub(self, other: ChatPermissions) -> ChatPermissions
The intersection of self with the complement of other (&!).
This method is not equivalent to self & !other when other has unknown bits set.
difference won’t truncate other, but the ! operator will.
Source§type Output = ChatPermissions
type Output = ChatPermissions
- operator.Source§impl SubAssign for ChatPermissions
impl SubAssign for ChatPermissions
Source§fn sub_assign(&mut self, other: ChatPermissions)
fn sub_assign(&mut self, other: ChatPermissions)
The intersection of self with the complement of other (&!).
This method is not equivalent to self & !other when other has unknown bits set.
difference won’t truncate other, but the ! operator will.
Auto Trait Implementations§
impl Forget for ChatPermissions
impl Freeze for ChatPermissionswhere
InternalBitFlags: Freeze,
impl Move for ChatPermissions
impl RefUnwindSafe for ChatPermissionswhere
InternalBitFlags: RefUnwindSafe,
impl Send for ChatPermissionswhere
InternalBitFlags: Send,
impl Sync for ChatPermissionswhere
InternalBitFlags: Sync,
impl Unpin for ChatPermissionswhere
InternalBitFlags: Unpin,
impl UnsafeUnpin for ChatPermissionswhere
InternalBitFlags: UnsafeUnpin,
impl UnwindSafe for ChatPermissionswhere
InternalBitFlags: 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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Erasable for T
impl<T> Erasable for T
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