@@ -27,7 +27,7 @@ pub fn validate_topic(topic: &str) -> Result<&str, Error> {
2727}
2828
2929#[ derive( Default , Clone , Debug , Serialize , Deserialize ) ]
30- pub struct Message {
30+ pub struct ReceivedMessage {
3131 pub id : String ,
3232 pub topic : String ,
3333 pub expires : Option < u64 > ,
@@ -59,7 +59,7 @@ pub struct Message {
5959 pub actions : Vec < Action > ,
6060}
6161
62- impl Message {
62+ impl ReceivedMessage {
6363 fn extend_with_emojis ( & self , text : & mut String ) {
6464 // Add emojis
6565 for t in & self . tags {
@@ -107,6 +107,37 @@ impl Message {
107107 }
108108}
109109
110+ #[ derive( Default , Clone , Debug , Serialize , Deserialize ) ]
111+ pub struct OutgoingMessage {
112+ pub topic : String ,
113+ pub message : Option < String > ,
114+ #[ serde( default = "Default::default" ) ]
115+ pub time : u64 ,
116+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
117+ pub title : Option < String > ,
118+ #[ serde( default ) ]
119+ #[ serde( skip_serializing_if = "Vec::is_empty" ) ]
120+ pub tags : Vec < String > ,
121+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
122+ pub priority : Option < i8 > ,
123+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
124+ #[ serde( default ) ]
125+ pub attachment : Option < Attachment > ,
126+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
127+ pub icon : Option < String > ,
128+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
129+ pub filename : Option < String > ,
130+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
131+ pub delay : Option < usize > ,
132+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
133+ pub email : Option < String > ,
134+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
135+ pub call : Option < String > ,
136+ #[ serde( default ) ]
137+ #[ serde( skip_serializing_if = "Vec::is_empty" ) ]
138+ pub actions : Vec < Action > ,
139+ }
140+
110141#[ derive( Clone , Debug , Serialize , Deserialize ) ]
111142pub struct MinMessage {
112143 pub id : String ,
@@ -167,7 +198,7 @@ impl Subscription {
167198 . push ( "auth" ) ;
168199 Ok ( url)
169200 }
170- pub fn validate ( self ) -> Result < Self , Vec < crate :: Error > > {
201+ pub fn validate ( self ) -> Result < Self , crate :: Error > {
171202 let mut errs = vec ! [ ] ;
172203 if let Err ( e) = validate_topic ( & self . topic ) {
173204 errs. push ( e) ;
@@ -176,7 +207,7 @@ impl Subscription {
176207 errs. push ( e) ;
177208 } ;
178209 if !errs. is_empty ( ) {
179- return Err ( errs) ;
210+ return Err ( Error :: InvalidSubscription ( errs) ) ;
180211 }
181212 Ok ( self )
182213 }
@@ -239,7 +270,7 @@ impl SubscriptionBuilder {
239270 self
240271 }
241272
242- pub fn build ( self ) -> Result < Subscription , Vec < Error > > {
273+ pub fn build ( self ) -> Result < Subscription , Error > {
243274 let res = Subscription {
244275 server : self . server ,
245276 topic : self . topic ,
0 commit comments