[−][src]Struct bot_rs_core::command_access::AccessRights  
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
- Noneif no filters were present for the message.
Trait Implementations
impl Clone for AccessRights[src]
fn clone(&self) -> AccessRights[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Debug for AccessRights[src]
impl Default for AccessRights[src]
fn default() -> AccessRights[src]
impl<'de> Deserialize<'de> for AccessRights[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
    __D: Deserializer<'de>, [src]
__D: Deserializer<'de>,
impl Eq for AccessRights[src]
impl PartialEq<AccessRights> for AccessRights[src]
fn eq(&self, other: &AccessRights) -> bool[src]
fn ne(&self, other: &AccessRights) -> bool[src]
impl Serialize for AccessRights[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
    __S: Serializer, [src]
__S: Serializer,
impl StructuralEq for AccessRights[src]
impl StructuralPartialEq for AccessRights[src]
Auto Trait Implementations
impl NotInvocErr for AccessRights
impl RefUnwindSafe for AccessRights
impl Send for AccessRights
impl Sync for AccessRights
impl Unpin for AccessRights
impl UnwindSafe for AccessRights
Blanket Implementations
impl<T> Any for T where
    T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
    T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
    T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, [src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
    U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
    T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
    U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
V: MultiLane<T>,