push: Add accessor for the RuleKind of Predefined{*}RuleId
This commit is contained in:
parent
ba75b09a45
commit
56d8a59c1b
@ -12,6 +12,7 @@ Improvements:
|
|||||||
- Add `MatrixVersion::V1_9`
|
- Add `MatrixVersion::V1_9`
|
||||||
- Point links to the Matrix 1.9 specification
|
- Point links to the Matrix 1.9 specification
|
||||||
- Implement `as_str()` and `AsRef<str>` for `push::PredefinedRuleId`
|
- Implement `as_str()` and `AsRef<str>` for `push::PredefinedRuleId`
|
||||||
|
- Implement `kind()` for `push::Predefined{*}RuleId`
|
||||||
|
|
||||||
# 0.12.1
|
# 0.12.1
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ use ruma_macros::StringEnum;
|
|||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
Action::*, ConditionalPushRule, PatternedPushRule, PushCondition::*, RoomMemberCountIs,
|
Action::*, ConditionalPushRule, PatternedPushRule, PushCondition::*, RoomMemberCountIs,
|
||||||
Ruleset, Tweak,
|
RuleKind, Ruleset, Tweak,
|
||||||
};
|
};
|
||||||
use crate::{PrivOwnedStr, UserId};
|
use crate::{PrivOwnedStr, UserId};
|
||||||
|
|
||||||
@ -564,6 +564,15 @@ impl PredefinedRuleId {
|
|||||||
Self::Content(id) => id.as_str(),
|
Self::Content(id) => id.as_str(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the kind of this `PredefinedRuleId`.
|
||||||
|
pub fn kind(&self) -> RuleKind {
|
||||||
|
match self {
|
||||||
|
Self::Override(id) => id.kind(),
|
||||||
|
Self::Underride(id) => id.kind(),
|
||||||
|
Self::Content(id) => id.kind(),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsRef<str> for PredefinedRuleId {
|
impl AsRef<str> for PredefinedRuleId {
|
||||||
@ -631,6 +640,13 @@ pub enum PredefinedOverrideRuleId {
|
|||||||
_Custom(PrivOwnedStr),
|
_Custom(PrivOwnedStr),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PredefinedOverrideRuleId {
|
||||||
|
/// Get the kind of this `PredefinedOverrideRuleId`.
|
||||||
|
pub fn kind(&self) -> RuleKind {
|
||||||
|
RuleKind::Override
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The rule IDs of the predefined underride server push rules.
|
/// The rule IDs of the predefined underride server push rules.
|
||||||
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
|
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
|
||||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
|
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
|
||||||
@ -692,6 +708,13 @@ pub enum PredefinedUnderrideRuleId {
|
|||||||
_Custom(PrivOwnedStr),
|
_Custom(PrivOwnedStr),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PredefinedUnderrideRuleId {
|
||||||
|
/// Get the kind of this `PredefinedUnderrideRuleId`.
|
||||||
|
pub fn kind(&self) -> RuleKind {
|
||||||
|
RuleKind::Underride
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The rule IDs of the predefined content server push rules.
|
/// The rule IDs of the predefined content server push rules.
|
||||||
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
|
#[doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/doc/string_enum.md"))]
|
||||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
|
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, StringEnum)]
|
||||||
@ -706,6 +729,13 @@ pub enum PredefinedContentRuleId {
|
|||||||
_Custom(PrivOwnedStr),
|
_Custom(PrivOwnedStr),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PredefinedContentRuleId {
|
||||||
|
/// Get the kind of this `PredefinedContentRuleId`.
|
||||||
|
pub fn kind(&self) -> RuleKind {
|
||||||
|
RuleKind::Content
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use assert_matches2::assert_matches;
|
use assert_matches2::assert_matches;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user