Struct twilight_cache_inmemory::permission::InMemoryCachePermissions[][src]

pub struct InMemoryCachePermissions<'a>(_);
This is supported on crate feature 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.

Calculate the permissions of a member in a guild channel.

Returns Permissions::all if the user is the owner of the guild.

The following ResourceTypes 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 ResourceTypes 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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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