pub struct CommunityChannel { /* private fields */ }Expand description
One channel of a Community, as Community::channels reports it.
Deliberately includes channels this bot cannot read: a private channel whose key hasn’t arrived is enumerable but unreadable, and a bot that can’t see the difference has no way to tell “nobody has talked to me” from “I was granted access and never got the key”.
Implementations§
Source§impl CommunityChannel
impl CommunityChannel
Sourcepub fn id(&self) -> &str
pub fn id(&self) -> &str
The channel id (32-byte hex) — what Community::channel takes.
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
The channel’s display name. Empty for a private channel recorded before its metadata folded.
Examples found in repository?
examples/concordia.rs (line 401)
392async fn print_channels(bot: &VectorBot, label: &str) {
393 for community in bot.communities().await {
394 let channels = community.channels().await;
395 if channels.is_empty() {
396 continue;
397 }
398 let rendered: Vec<String> = channels
399 .iter()
400 .map(|ch| match (ch.is_private(), ch.is_readable()) {
401 (true, false) => format!("#{} (locked)", ch.name()),
402 (true, true) => format!("#{} (private)", ch.name()),
403 _ => format!("#{}", ch.name()),
404 })
405 .collect();
406 println!("── {label} in {}: {}", short(community.id()), rendered.join(", "));
407 }
408}Sourcepub fn is_private(&self) -> bool
pub fn is_private(&self) -> bool
Whether this channel is private (independently keyed, readable only by granted role-holders).
Examples found in repository?
examples/concordia.rs (line 400)
392async fn print_channels(bot: &VectorBot, label: &str) {
393 for community in bot.communities().await {
394 let channels = community.channels().await;
395 if channels.is_empty() {
396 continue;
397 }
398 let rendered: Vec<String> = channels
399 .iter()
400 .map(|ch| match (ch.is_private(), ch.is_readable()) {
401 (true, false) => format!("#{} (locked)", ch.name()),
402 (true, true) => format!("#{} (private)", ch.name()),
403 _ => format!("#{}", ch.name()),
404 })
405 .collect();
406 println!("── {label} in {}: {}", short(community.id()), rendered.join(", "));
407 }
408}Sourcepub fn is_readable(&self) -> bool
pub fn is_readable(&self) -> bool
Whether this bot can actually read it. False only for a private channel
whose key hasn’t been delivered yet — see Community::channels.
Examples found in repository?
examples/concordia.rs (line 400)
392async fn print_channels(bot: &VectorBot, label: &str) {
393 for community in bot.communities().await {
394 let channels = community.channels().await;
395 if channels.is_empty() {
396 continue;
397 }
398 let rendered: Vec<String> = channels
399 .iter()
400 .map(|ch| match (ch.is_private(), ch.is_readable()) {
401 (true, false) => format!("#{} (locked)", ch.name()),
402 (true, true) => format!("#{} (private)", ch.name()),
403 _ => format!("#{}", ch.name()),
404 })
405 .collect();
406 println!("── {label} in {}: {}", short(community.id()), rendered.join(", "));
407 }
408}Trait Implementations§
Source§impl Clone for CommunityChannel
impl Clone for CommunityChannel
Source§fn clone(&self) -> CommunityChannel
fn clone(&self) -> CommunityChannel
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CommunityChannel
impl Debug for CommunityChannel
Source§impl<'de> Deserialize<'de> for CommunityChannel
impl<'de> Deserialize<'de> for CommunityChannel
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for CommunityChannel
impl RefUnwindSafe for CommunityChannel
impl Send for CommunityChannel
impl Sync for CommunityChannel
impl Unpin for CommunityChannel
impl UnsafeUnpin for CommunityChannel
impl UnwindSafe for CommunityChannel
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
Mutably borrows from an owned value. Read more
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> 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> ⓘ
Converts
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> ⓘ
Converts
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