Struct ruma_common::push::Ruleset
source · [−]#[non_exhaustive]pub struct Ruleset {
pub content: IndexSet<PatternedPushRule>,
pub override_: IndexSet<ConditionalPushRule>,
pub room: IndexSet<SimplePushRule>,
pub sender: IndexSet<SimplePushRule>,
pub underride: IndexSet<ConditionalPushRule>,
}
Expand description
A push ruleset scopes a set of rules according to some criteria.
For example, some rules may only be applied for messages from a particular sender, a particular room, or by default. The push ruleset contains the entire set of scopes and rules.
Fields (Non-exhaustive)
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.content: IndexSet<PatternedPushRule>
These rules configure behavior for (unencrypted) messages that match certain patterns.
override_: IndexSet<ConditionalPushRule>
These user-configured rules are given the highest priority.
This field is named override_
instead of override
because the latter is a reserved
keyword in Rust.
room: IndexSet<SimplePushRule>
These rules change the behavior of all messages for a given room.
sender: IndexSet<SimplePushRule>
These rules configure notification behavior for messages from a specific Matrix user ID.
underride: IndexSet<ConditionalPushRule>
These rules are identical to override rules, but have a lower priority than content
,
room
and sender
rules.
Implementations
sourceimpl Ruleset
impl Ruleset
sourcepub fn server_default(user_id: &UserId) -> Self
pub fn server_default(user_id: &UserId) -> Self
The list of all predefined push rules.
Parameters
user_id
: the user for which to generate the default rules. Some rules depend on the user’s ID (for instance those to send notifications when they are mentioned).
sourceimpl Ruleset
impl Ruleset
sourcepub fn iter(&self) -> RulesetIter<'_>ⓘNotable traits for RulesetIter<'a>impl<'a> Iterator for RulesetIter<'a> type Item = AnyPushRuleRef<'a>;
pub fn iter(&self) -> RulesetIter<'_>ⓘNotable traits for RulesetIter<'a>impl<'a> Iterator for RulesetIter<'a> type Item = AnyPushRuleRef<'a>;
Creates a borrowing iterator over all push rules in this Ruleset
.
For an owning iterator, use .into_iter()
.
sourcepub fn add(&mut self, rule: AnyPushRule) -> bool
pub fn add(&mut self, rule: AnyPushRule) -> bool
Adds a rule to the rule set.
Returns true
if the new rule was correctly added, and false
if a rule with the same rule_id
is already present for this kind
of rule.
sourcepub fn get_match<T>(
&self,
event: &Raw<T>,
context: &PushConditionRoomCtx
) -> Option<AnyPushRuleRef<'_>>
pub fn get_match<T>(
&self,
event: &Raw<T>,
context: &PushConditionRoomCtx
) -> Option<AnyPushRuleRef<'_>>
Get the first push rule that applies to this event, if any.
Arguments
event
- The raw JSON of a room message event.context
- The context of the message and room at the time of the event.
sourcepub fn get_actions<T>(
&self,
event: &Raw<T>,
context: &PushConditionRoomCtx
) -> &[Action]
pub fn get_actions<T>(
&self,
event: &Raw<T>,
context: &PushConditionRoomCtx
) -> &[Action]
Get the push actions that apply to this event.
Returns an empty slice if no push rule applies.
Arguments
event
- The raw JSON of a room message event.context
- The context of the message and room at the time of the event.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Ruleset
impl<'de> Deserialize<'de> for Ruleset
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Extend<AnyPushRule> for Ruleset
impl Extend<AnyPushRule> for Ruleset
sourcefn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = AnyPushRule>,
fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = AnyPushRule>,
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl From<Ruleset> for PushRulesEventContent
impl From<Ruleset> for PushRulesEventContent
sourceimpl IntoIterator for Ruleset
impl IntoIterator for Ruleset
type Item = AnyPushRule
type Item = AnyPushRule
The type of the elements being iterated over.
type IntoIter = RulesetIntoIter
type IntoIter = RulesetIntoIter
Which kind of iterator are we turning this into?
sourceimpl<'a> IntoIterator for &'a Ruleset
impl<'a> IntoIterator for &'a Ruleset
type Item = AnyPushRuleRef<'a>
type Item = AnyPushRuleRef<'a>
The type of the elements being iterated over.
type IntoIter = RulesetIter<'a>
type IntoIter = RulesetIter<'a>
Which kind of iterator are we turning this into?
Auto Trait Implementations
impl RefUnwindSafe for Ruleset
impl Send for Ruleset
impl Sync for Ruleset
impl Unpin for Ruleset
impl UnwindSafe for Ruleset
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more