Rename PushRule to SimplePushRule
This commit is contained in:
parent
5d988db5e7
commit
1a29875fb4
@ -17,7 +17,7 @@
|
|||||||
//! Each of these kind of rule has a corresponding type, that is
|
//! Each of these kind of rule has a corresponding type, that is
|
||||||
//! just a wrapper arround another type:
|
//! just a wrapper arround another type:
|
||||||
//!
|
//!
|
||||||
//! - `PushRule` for room and sender rules
|
//! - `SimplePushRule` for room and sender rules
|
||||||
//! - `ConditionalPushRule` for override and underride rules: push rules that may depend on a
|
//! - `ConditionalPushRule` for override and underride rules: push rules that may depend on a
|
||||||
//! condition
|
//! condition
|
||||||
//! - `PatternedPushRules` for content rules, that can filter events based on a pattern to trigger
|
//! - `PatternedPushRules` for content rules, that can filter events based on a pattern to trigger
|
||||||
@ -29,7 +29,7 @@
|
|||||||
//! the same representation.
|
//! the same representation.
|
||||||
//!
|
//!
|
||||||
//! It is still possible to write code that is generic over a representation by manipulating
|
//! It is still possible to write code that is generic over a representation by manipulating
|
||||||
//! `PushRule`, `ConditonalPushRule` or `PatternedPushRule` directly, instead of the wrappers.
|
//! `SimplePushRule`, `ConditonalPushRule` or `PatternedPushRule` directly, instead of the wrappers.
|
||||||
//!
|
//!
|
||||||
//! There is also the `AnyPushRule` type that is the most generic form of push rule, with all
|
//! There is also the `AnyPushRule` type that is the most generic form of push rule, with all
|
||||||
//! the possible fields.
|
//! the possible fields.
|
||||||
@ -117,7 +117,7 @@ pub trait RulesetMember {
|
|||||||
fn add_to(self, ruleset: &mut Ruleset) -> bool;
|
fn add_to(self, ruleset: &mut Ruleset) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new wrapper type around a PushRule type
|
/// Creates a new wrapper type around a PushRule-like type
|
||||||
/// to make it possible to tell what kind of rule it is
|
/// to make it possible to tell what kind of rule it is
|
||||||
/// even if the inner type is the same.
|
/// even if the inner type is the same.
|
||||||
///
|
///
|
||||||
@ -173,8 +173,8 @@ macro_rules! rulekind {
|
|||||||
|
|
||||||
rulekind!(OverridePushRule, ConditionalPushRule, override_);
|
rulekind!(OverridePushRule, ConditionalPushRule, override_);
|
||||||
rulekind!(UnderridePushRule, ConditionalPushRule, underride);
|
rulekind!(UnderridePushRule, ConditionalPushRule, underride);
|
||||||
rulekind!(RoomPushRule, PushRule, room);
|
rulekind!(RoomPushRule, SimplePushRule, room);
|
||||||
rulekind!(SenderPushRule, PushRule, sender);
|
rulekind!(SenderPushRule, SimplePushRule, sender);
|
||||||
rulekind!(ContentPushRule, PatternedPushRule, content);
|
rulekind!(ContentPushRule, PatternedPushRule, content);
|
||||||
|
|
||||||
/// A push rule is a single rule that states under what conditions an event should be passed onto a
|
/// A push rule is a single rule that states under what conditions an event should be passed onto a
|
||||||
@ -183,11 +183,11 @@ rulekind!(ContentPushRule, PatternedPushRule, content);
|
|||||||
/// These rules are stored on the user's homeserver. They are manually configured by the user, who
|
/// These rules are stored on the user's homeserver. They are manually configured by the user, who
|
||||||
/// can create and view them via the Client/Server API.
|
/// can create and view them via the Client/Server API.
|
||||||
///
|
///
|
||||||
/// To create an instance of this type, first create a `PushRuleInit` and convert it via
|
/// To create an instance of this type, first create a `SimplePushRuleInit` and convert it via
|
||||||
/// `PushRule::from` / `.into()`.
|
/// `SimplePushRule::from` / `.into()`.
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
pub struct PushRule {
|
pub struct SimplePushRule {
|
||||||
/// Actions to determine if and how a notification is delivered for events matching this rule.
|
/// Actions to determine if and how a notification is delivered for events matching this rule.
|
||||||
pub actions: Vec<Action>,
|
pub actions: Vec<Action>,
|
||||||
|
|
||||||
@ -201,12 +201,12 @@ pub struct PushRule {
|
|||||||
pub rule_id: String,
|
pub rule_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initial set of fields of `PushRule`.
|
/// Initial set of fields of `SimplePushRule`.
|
||||||
///
|
///
|
||||||
/// This struct will not be updated even if additional fields are added to `PushRule` in a new
|
/// This struct will not be updated even if additional fields are added to `SimplePushRule` in a new
|
||||||
/// (non-breaking) release of the Matrix specification.
|
/// (non-breaking) release of the Matrix specification.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct PushRuleInit {
|
pub struct SimplePushRuleInit {
|
||||||
/// Actions to determine if and how a notification is delivered for events matching this rule.
|
/// Actions to determine if and how a notification is delivered for events matching this rule.
|
||||||
pub actions: Vec<Action>,
|
pub actions: Vec<Action>,
|
||||||
|
|
||||||
@ -220,14 +220,14 @@ pub struct PushRuleInit {
|
|||||||
pub rule_id: String,
|
pub rule_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<PushRuleInit> for PushRule {
|
impl From<SimplePushRuleInit> for SimplePushRule {
|
||||||
fn from(init: PushRuleInit) -> Self {
|
fn from(init: SimplePushRuleInit) -> Self {
|
||||||
let PushRuleInit { actions, default, enabled, rule_id } = init;
|
let SimplePushRuleInit { actions, default, enabled, rule_id } = init;
|
||||||
Self { actions, default, enabled, rule_id }
|
Self { actions, default, enabled, rule_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Like `PushRule`, but with an additional `conditions` field.
|
/// Like `SimplePushRule`, but with an additional `conditions` field.
|
||||||
///
|
///
|
||||||
/// Only applicable to underride and override rules.
|
/// Only applicable to underride and override rules.
|
||||||
///
|
///
|
||||||
@ -287,7 +287,7 @@ impl From<ConditionalPushRuleInit> for ConditionalPushRule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Like `PushRule`, but with an additional `pattern` field.
|
/// Like `SimplePushRule`, but with an additional `pattern` field.
|
||||||
///
|
///
|
||||||
/// Only applicable to content rules.
|
/// Only applicable to content rules.
|
||||||
///
|
///
|
||||||
|
@ -8,10 +8,10 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
Action, ConditionalPushRule, ConditionalPushRuleInit, PatternedPushRule, PatternedPushRuleInit,
|
Action, ConditionalPushRule, ConditionalPushRuleInit, PatternedPushRule, PatternedPushRuleInit,
|
||||||
PushCondition, PushRule, PushRuleInit,
|
PushCondition, SimplePushRule, SimplePushRuleInit,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Like `PushRule`, but may represent any kind of push rule
|
/// Like `SimplePushRule`, but may represent any kind of push rule
|
||||||
/// thanks to `pattern` and `conditions` being optional.
|
/// thanks to `pattern` and `conditions` being optional.
|
||||||
///
|
///
|
||||||
/// To create an instance of this type, use one of its `From` implementations.
|
/// To create an instance of this type, use one of its `From` implementations.
|
||||||
@ -42,9 +42,9 @@ pub struct AnyPushRule {
|
|||||||
pub pattern: Option<String>,
|
pub pattern: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<PushRule> for AnyPushRule {
|
impl From<SimplePushRule> for AnyPushRule {
|
||||||
fn from(push_rule: PushRule) -> Self {
|
fn from(push_rule: SimplePushRule) -> Self {
|
||||||
let PushRule { actions, default, enabled, rule_id } = push_rule;
|
let SimplePushRule { actions, default, enabled, rule_id } = push_rule;
|
||||||
Self { actions, default, enabled, rule_id, conditions: None, pattern: None }
|
Self { actions, default, enabled, rule_id, conditions: None, pattern: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,9 +63,9 @@ impl From<ConditionalPushRule> for AnyPushRule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<PushRuleInit> for AnyPushRule {
|
impl From<SimplePushRuleInit> for AnyPushRule {
|
||||||
fn from(init: PushRuleInit) -> Self {
|
fn from(init: SimplePushRuleInit) -> Self {
|
||||||
let PushRuleInit { actions, default, enabled, rule_id } = init;
|
let SimplePushRuleInit { actions, default, enabled, rule_id } = init;
|
||||||
Self { actions, default, enabled, rule_id, pattern: None, conditions: None }
|
Self { actions, default, enabled, rule_id, pattern: None, conditions: None }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,10 +84,10 @@ impl From<PatternedPushRuleInit> for AnyPushRule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<AnyPushRule> for PushRule {
|
impl From<AnyPushRule> for SimplePushRule {
|
||||||
fn from(push_rule: AnyPushRule) -> Self {
|
fn from(push_rule: AnyPushRule) -> Self {
|
||||||
let AnyPushRule { actions, default, enabled, rule_id, .. } = push_rule;
|
let AnyPushRule { actions, default, enabled, rule_id, .. } = push_rule;
|
||||||
PushRule { actions, default, enabled, rule_id }
|
Self { actions, default, enabled, rule_id }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user