From 1a29875fb4c479e9cd2652ccc24049d01b5d82ad Mon Sep 17 00:00:00 2001 From: Ana Gelez Date: Fri, 27 Nov 2020 19:22:50 +0100 Subject: [PATCH] Rename PushRule to SimplePushRule --- ruma-common/src/push.rs | 32 +++++++++++++-------------- ruma-common/src/push/any_push_rule.rs | 20 ++++++++--------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/ruma-common/src/push.rs b/ruma-common/src/push.rs index 9f06740d..f0c74c37 100644 --- a/ruma-common/src/push.rs +++ b/ruma-common/src/push.rs @@ -17,7 +17,7 @@ //! Each of these kind of rule has a corresponding type, that is //! 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 //! condition //! - `PatternedPushRules` for content rules, that can filter events based on a pattern to trigger @@ -29,7 +29,7 @@ //! the same representation. //! //! 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 //! the possible fields. @@ -117,7 +117,7 @@ pub trait RulesetMember { 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 /// even if the inner type is the same. /// @@ -173,8 +173,8 @@ macro_rules! rulekind { rulekind!(OverridePushRule, ConditionalPushRule, override_); rulekind!(UnderridePushRule, ConditionalPushRule, underride); -rulekind!(RoomPushRule, PushRule, room); -rulekind!(SenderPushRule, PushRule, sender); +rulekind!(RoomPushRule, SimplePushRule, room); +rulekind!(SenderPushRule, SimplePushRule, sender); rulekind!(ContentPushRule, PatternedPushRule, content); /// 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 /// 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 -/// `PushRule::from` / `.into()`. +/// To create an instance of this type, first create a `SimplePushRuleInit` and convert it via +/// `SimplePushRule::from` / `.into()`. #[derive(Clone, Debug, Deserialize, Serialize)] #[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. pub actions: Vec, @@ -201,12 +201,12 @@ pub struct PushRule { 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. #[derive(Debug)] -pub struct PushRuleInit { +pub struct SimplePushRuleInit { /// Actions to determine if and how a notification is delivered for events matching this rule. pub actions: Vec, @@ -220,14 +220,14 @@ pub struct PushRuleInit { pub rule_id: String, } -impl From for PushRule { - fn from(init: PushRuleInit) -> Self { - let PushRuleInit { actions, default, enabled, rule_id } = init; +impl From for SimplePushRule { + fn from(init: SimplePushRuleInit) -> Self { + let SimplePushRuleInit { actions, default, enabled, rule_id } = init; 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. /// @@ -287,7 +287,7 @@ impl From for ConditionalPushRule { } } -/// Like `PushRule`, but with an additional `pattern` field. +/// Like `SimplePushRule`, but with an additional `pattern` field. /// /// Only applicable to content rules. /// diff --git a/ruma-common/src/push/any_push_rule.rs b/ruma-common/src/push/any_push_rule.rs index 2e10e3b1..33d7836b 100644 --- a/ruma-common/src/push/any_push_rule.rs +++ b/ruma-common/src/push/any_push_rule.rs @@ -8,10 +8,10 @@ use serde::{Deserialize, Serialize}; use super::{ 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. /// /// To create an instance of this type, use one of its `From` implementations. @@ -42,9 +42,9 @@ pub struct AnyPushRule { pub pattern: Option, } -impl From for AnyPushRule { - fn from(push_rule: PushRule) -> Self { - let PushRule { actions, default, enabled, rule_id } = push_rule; +impl From for AnyPushRule { + fn from(push_rule: SimplePushRule) -> Self { + let SimplePushRule { actions, default, enabled, rule_id } = push_rule; Self { actions, default, enabled, rule_id, conditions: None, pattern: None } } } @@ -63,9 +63,9 @@ impl From for AnyPushRule { } } -impl From for AnyPushRule { - fn from(init: PushRuleInit) -> Self { - let PushRuleInit { actions, default, enabled, rule_id } = init; +impl From for AnyPushRule { + fn from(init: SimplePushRuleInit) -> Self { + let SimplePushRuleInit { actions, default, enabled, rule_id } = init; Self { actions, default, enabled, rule_id, pattern: None, conditions: None } } } @@ -84,10 +84,10 @@ impl From for AnyPushRule { } } -impl From for PushRule { +impl From for SimplePushRule { fn from(push_rule: AnyPushRule) -> Self { let AnyPushRule { actions, default, enabled, rule_id, .. } = push_rule; - PushRule { actions, default, enabled, rule_id } + Self { actions, default, enabled, rule_id } } }