@@ -5,7 +5,7 @@ use serde::Deserialize;
55use spdlog:: prelude:: * ;
66
77use crate :: {
8- config:: { self , Overridable } ,
8+ config:: { Accessor , Overridable , Validator } ,
99 platform:: * ,
1010 source:: Notification ,
1111} ;
@@ -14,11 +14,11 @@ use crate::{
1414#[ serde( tag = "platform" ) ]
1515pub enum NotifierConfig {
1616 #[ serde( rename = "QQ" ) ]
17- Qq ( config :: Accessor < qq:: notify:: ConfigParams > ) ,
18- Telegram ( config :: Accessor < telegram:: notify:: ConfigParams > ) ,
17+ Qq ( Accessor < qq:: notify:: ConfigParams > ) ,
18+ Telegram ( Accessor < telegram:: notify:: ConfigParams > ) ,
1919}
2020
21- impl config :: Validator for NotifierConfig {
21+ impl Validator for NotifierConfig {
2222 fn validate ( & self ) -> anyhow:: Result < ( ) > {
2323 match self {
2424 Self :: Qq ( p) => p. validate ( ) ,
@@ -35,16 +35,15 @@ impl NotifierConfig {
3535 {
3636 match self {
3737 Self :: Qq ( n) => {
38- let new: <qq:: notify:: ConfigParams as config:: Overridable >:: Override =
39- new. try_into ( ) ?;
40- Ok ( Self :: Qq ( config:: Accessor :: new_then_validate (
38+ let new: <qq:: notify:: ConfigParams as Overridable >:: Override = new. try_into ( ) ?;
39+ Ok ( Self :: Qq ( Accessor :: new_then_validate (
4140 n. into_inner ( ) . override_into ( new) ,
4241 ) ?) )
4342 }
4443 Self :: Telegram ( n) => {
45- let new: <telegram:: notify:: ConfigParams as config :: Overridable >:: Override =
44+ let new: <telegram:: notify:: ConfigParams as Overridable >:: Override =
4645 new. try_into ( ) ?;
47- Ok ( Self :: Telegram ( config :: Accessor :: new_then_validate (
46+ Ok ( Self :: Telegram ( Accessor :: new_then_validate (
4847 n. into_inner ( ) . override_into ( new) ,
4948 ) ?) )
5049 }
@@ -68,7 +67,7 @@ pub trait NotifierTrait: PlatformTrait {
6867 ) -> Pin < Box < dyn Future < Output = anyhow:: Result < ( ) > > + Send + ' a > > ;
6968}
7069
71- pub fn notifier ( params : config :: Accessor < NotifierConfig > ) -> Box < dyn NotifierTrait > {
70+ pub fn notifier ( params : Accessor < NotifierConfig > ) -> Box < dyn NotifierTrait > {
7271 match params. into_inner ( ) {
7372 NotifierConfig :: Qq ( p) => Box :: new ( qq:: notify:: Notifier :: new ( p) ) ,
7473 NotifierConfig :: Telegram ( p) => Box :: new ( telegram:: notify:: Notifier :: new ( p) ) ,
0 commit comments