@@ -4,7 +4,7 @@ use super::{
44} ;
55use crate :: event:: attributes:: DataAttributesWriter ;
66use chrono:: { DateTime , Utc } ;
7- use delegate :: delegate;
7+ use delegate_attr :: delegate;
88use std:: collections:: HashMap ;
99use std:: convert:: TryFrom ;
1010use url:: Url ;
@@ -40,31 +40,25 @@ pub struct Event {
4040 pub ( crate ) extensions : HashMap < String , ExtensionValue > ,
4141}
4242
43+ #[ delegate( self . attributes) ]
4344impl 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 > > ;
5653}
5754
55+ #[ delegate( self . attributes) ]
5856impl 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 > > > ) ;
6862}
6963
7064impl Default for Event {
0 commit comments