[][src]Struct bot_rs_core::command_access::AccessRights

pub struct AccessRights { /* fields omitted */ }

Manages filters for command invocations. Should be used to manage the access of users to commands based on the messages.

Example

Its recommended to use this before processing the command.

use bot_rs_core::plugin::{Plugin, PluginInfo, PluginError};
use bot_rs_core::Message;
use async_trait::async_trait;
use bot_rs_core::profile::{Profiles, Profile};

// Profile can be stored on Plugin creation as active profile doesn't change at runtime
struct TestPlugin(Profile);

#[async_trait]
impl Plugin for TestPlugin{
    type Error = PluginError;

    async fn call(&self, message: Message) -> Result<Vec<Message>, PluginError> {
        match self.0.rights().allowed(&message) {
            Some(true) => (),// Message was checked by a AccessFilter and is allowed,
            Some(false) => (),// Message was checked by a AccessFilter and is not allowed
            None => (), // Message has no handling AccessFilters
        }
        Ok(Vec::with_capacity(0))
    }

    fn info(&self) -> PluginInfo {
        unimplemented!()
    }
}

Implementations

impl AccessRights[src]

pub fn new() -> Self[src]

pub fn is_empty(&self) -> bool[src]

Returns if there are no filters.

pub fn iter(&self) -> impl Iterator<Item = &AccessFilter>[src]

Returns an Iterator over all

pub fn allowed(&self, mssg: &Message) -> Option<bool>[src]

Checks if any filter allows the invocation of a command.

Returns:

  • Some(true) if filters were present for the message and any allowed it,
  • Some(false) if filters were present for the message and none allowed it and
  • None if no filters were present for the message.

Trait Implementations

impl Clone for AccessRights[src]

impl Debug for AccessRights[src]

impl Default for AccessRights[src]

impl<'de> Deserialize<'de> for AccessRights[src]

impl Eq for AccessRights[src]

impl PartialEq<AccessRights> for AccessRights[src]

impl Serialize for AccessRights[src]

impl StructuralEq for AccessRights[src]

impl StructuralPartialEq for AccessRights[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,