Enum discord_flows::model::Channel
source · pub enum Channel {
Guild(GuildChannel),
Private(PrivateChannel),
Category(ChannelCategory),
}
Expand description
A container for any channel.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Guild(GuildChannel)
Private(PrivateChannel)
A private channel to another User
. No other users may access the
channel.
Category(ChannelCategory)
A category of GuildChannel
s
Implementations§
source§impl Channel
impl Channel
sourcepub fn guild(self) -> Option<GuildChannel>
pub fn guild(self) -> Option<GuildChannel>
Converts from Channel
to Option<GuildChannel>
.
Converts self
into an Option<GuildChannel>
, consuming
self
, and discarding a PrivateChannel
, or
ChannelCategory
, if any.
Examples
Basic usage:
match channel.guild() {
Some(guild_channel) => {
println!("It's a guild channel named {}!", guild_channel.name);
},
None => {
println!("It's not in a guild!");
},
}
sourcepub fn private(self) -> Option<PrivateChannel>
pub fn private(self) -> Option<PrivateChannel>
Converts from Channel
to Option<PrivateChannel>
.
Converts self
into an Option<PrivateChannel>
, consuming
self
, and discarding a GuildChannel
, or ChannelCategory
,
if any.
Examples
Basic usage:
match channel.private() {
Some(private) => {
println!("It's a private channel with {}!", &private.recipient);
},
None => {
println!("It's not a private channel!");
},
}
sourcepub fn category(self) -> Option<ChannelCategory>
pub fn category(self) -> Option<ChannelCategory>
Converts from Channel
to Option<ChannelCategory>
.
Converts self
into an Option<ChannelCategory>
,
consuming self
, and discarding a GuildChannel
, or
PrivateChannel
, if any.
Examples
Basic usage:
match channel.category() {
Some(category) => {
println!("It's a category named {}!", category.name);
},
None => {
println!("It's not a category!");
},
}
sourcepub fn id(&self) -> ChannelId
pub fn id(&self) -> ChannelId
Retrieves the Id of the inner GuildChannel
, or
PrivateChannel
.
sourcepub fn position(&self) -> Option<i64>
pub fn position(&self) -> Option<i64>
Retrieves the position of the inner GuildChannel
or
ChannelCategory
.
If other channel types are used it will return None.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Channel
impl<'de> Deserialize<'de> for Channel
source§fn deserialize<D>(
deserializer: D
) -> Result<Channel, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>( deserializer: D ) -> Result<Channel, <D as Deserializer<'de>>::Error>where D: Deserializer<'de>,
source§impl Display for Channel
impl Display for Channel
source§fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
Formats the channel into a “mentioned” string.
This will return a different format for each type of channel:
PrivateChannel
s: the recipient’s name;GuildChannel
s: a string mentioning the channel that users who can see the channel can click on.