Struct twilight_cache_inmemory::permission::InMemoryCachePermissions [−][src]
pub struct InMemoryCachePermissions<'a>(_);
permission-calculator
only.Expand description
Calculate the permissions of a member with information from the cache.
Implementations
Immutable reference to the underlying cache.
Consume the statistics interface, returning the underlying cache reference.
pub fn in_channel(
&self,
user_id: UserId,
channel_id: ChannelId
) -> Result<Permissions, ChannelError>
pub fn in_channel(
&self,
user_id: UserId,
channel_id: ChannelId
) -> Result<Permissions, ChannelError>
Calculate the permissions of a member in a guild channel.
Returns Permissions::all
if the user is the owner of the guild.
The following ResourceType
s must be enabled:
Examples
use twilight_cache_inmemory::InMemoryCache;
use twilight_model::id::{ChannelId, UserId};
let cache = InMemoryCache::new();
// later on...
let channel_id = ChannelId::new(4).expect("non zero");
let user_id = UserId::new(5).expect("non zero");
let permissions = cache.permissions().in_channel(user_id, channel_id)?;
println!(
"User {} in channel {} has permissions {:?}",
user_id,
channel_id,
permissions,
);
Errors
Returns a ChannelErrorType::ChannelUnavailable
error type if the
guild channel is not in the cache.
Returns a ChannelErrorType::MemberUnavailable
error type if the
member for the user in the guild is not present.
Returns a ChannelErrorType::RoleUnavailable
error type if one of the
member’s roles is not in the cache.
Calculate the guild-level permissions of a member.
Returns Permissions::all
if the user is the owner of the guild.
The following ResourceType
s must be enabled:
Examples
use twilight_cache_inmemory::InMemoryCache;
use twilight_model::id::{GuildId, UserId};
let cache = InMemoryCache::new();
// later on...
let guild_id = GuildId::new(4).expect("non zero");
let user_id = UserId::new(5).expect("non zero");
let permissions = cache.permissions().root(user_id, guild_id)?;
println!(
"User {} in guild {} has permissions {:?}",
user_id,
guild_id,
permissions,
);
Errors
Returns a RootErrorType::MemberUnavailable
error type if the
member for the user in the guild is not present.
Returns a RootErrorType::RoleUnavailable
error type if one of the
member’s roles is not in the cache.
Trait Implementations
Auto Trait Implementations
impl<'a> !RefUnwindSafe for InMemoryCachePermissions<'a>
impl<'a> Send for InMemoryCachePermissions<'a>
impl<'a> Sync for InMemoryCachePermissions<'a>
impl<'a> Unpin for InMemoryCachePermissions<'a>
impl<'a> !UnwindSafe for InMemoryCachePermissions<'a>
Blanket Implementations
Mutably borrows from an owned value. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more