@@ -4,7 +4,7 @@ use super::{
4
4
} ;
5
5
use crate :: event:: attributes:: DataAttributesWriter ;
6
6
use chrono:: { DateTime , Utc } ;
7
- use delegate :: delegate;
7
+ use delegate_attr :: delegate;
8
8
use std:: collections:: HashMap ;
9
9
use std:: convert:: TryFrom ;
10
10
use url:: Url ;
@@ -40,31 +40,25 @@ pub struct Event {
40
40
pub ( crate ) extensions : HashMap < String , ExtensionValue > ,
41
41
}
42
42
43
+ #[ delegate( self . attributes) ]
43
44
impl AttributesReader for Event {
44
- delegate ! {
45
- to self . attributes {
46
- fn get_id( & self ) -> & str ;
47
- fn get_source( & self ) -> & Url ;
48
- fn get_specversion( & self ) -> SpecVersion ;
49
- fn get_type( & self ) -> & str ;
50
- fn get_datacontenttype( & self ) -> Option <& str >;
51
- fn get_dataschema( & self ) -> Option <& Url >;
52
- fn get_subject( & self ) -> Option <& str >;
53
- fn get_time( & self ) -> Option <& DateTime <Utc >>;
54
- }
55
- }
45
+ fn get_id ( & self ) -> & str ;
46
+ fn get_source ( & self ) -> & Url ;
47
+ fn get_specversion ( & self ) -> SpecVersion ;
48
+ fn get_type ( & self ) -> & str ;
49
+ fn get_datacontenttype ( & self ) -> Option < & str > ;
50
+ fn get_dataschema ( & self ) -> Option < & Url > ;
51
+ fn get_subject ( & self ) -> Option < & str > ;
52
+ fn get_time ( & self ) -> Option < & DateTime < Utc > > ;
56
53
}
57
54
55
+ #[ delegate( self . attributes) ]
58
56
impl AttributesWriter for Event {
59
- delegate ! {
60
- to self . attributes {
61
- fn set_id( & mut self , id: impl Into <String >) ;
62
- fn set_source( & mut self , source: impl Into <Url >) ;
63
- fn set_type( & mut self , ty: impl Into <String >) ;
64
- fn set_subject( & mut self , subject: Option <impl Into <String >>) ;
65
- fn set_time( & mut self , time: Option <impl Into <DateTime <Utc >>>) ;
66
- }
67
- }
57
+ fn set_id ( & mut self , id : impl Into < String > ) ;
58
+ fn set_source ( & mut self , source : impl Into < Url > ) ;
59
+ fn set_type ( & mut self , ty : impl Into < String > ) ;
60
+ fn set_subject ( & mut self , subject : Option < impl Into < String > > ) ;
61
+ fn set_time ( & mut self , time : Option < impl Into < DateTime < Utc > > > ) ;
68
62
}
69
63
70
64
impl Default for Event {
0 commit comments