11use crate :: event:: attributes:: { default_hostname, AttributeValue , AttributesConverter } ;
2- use crate :: event:: AttributesV10 ;
3- use crate :: event:: { AttributesReader , AttributesWriter , SpecVersion } ;
2+ use crate :: event:: { AttributesReader , AttributesV10 , AttributesWriter , SpecVersion , UriReference } ;
43use crate :: message:: { BinarySerializer , MessageAttributeValue } ;
54use chrono:: { DateTime , Utc } ;
65use url:: Url ;
@@ -22,7 +21,7 @@ pub(crate) const ATTRIBUTE_NAMES: [&str; 8] = [
2221pub struct Attributes {
2322 pub ( crate ) id : String ,
2423 pub ( crate ) ty : String ,
25- pub ( crate ) source : Url ,
24+ pub ( crate ) source : UriReference ,
2625 pub ( crate ) datacontenttype : Option < String > ,
2726 pub ( crate ) schemaurl : Option < Url > ,
2827 pub ( crate ) subject : Option < String > ,
@@ -64,7 +63,7 @@ impl<'a> Iterator for AttributesIntoIterator<'a> {
6463 . attributes
6564 . schemaurl
6665 . as_ref ( )
67- . map ( |v| ( "schemaurl" , AttributeValue :: URIRef ( v) ) ) ,
66+ . map ( |v| ( "schemaurl" , AttributeValue :: URI ( v) ) ) ,
6867 6 => self
6968 . attributes
7069 . subject
@@ -90,7 +89,7 @@ impl AttributesReader for Attributes {
9089 & self . id
9190 }
9291
93- fn source ( & self ) -> & Url {
92+ fn source ( & self ) -> & UriReference {
9493 & self . source
9594 }
9695
@@ -124,7 +123,7 @@ impl AttributesWriter for Attributes {
124123 std:: mem:: replace ( & mut self . id , id. into ( ) )
125124 }
126125
127- fn set_source ( & mut self , source : impl Into < Url > ) -> Url {
126+ fn set_source ( & mut self , source : impl Into < UriReference > ) -> UriReference {
128127 std:: mem:: replace ( & mut self . source , source. into ( ) )
129128 }
130129
@@ -157,7 +156,7 @@ impl Default for Attributes {
157156 Attributes {
158157 id : Uuid :: new_v4 ( ) . to_string ( ) ,
159158 ty : "type" . to_string ( ) ,
160- source : default_hostname ( ) ,
159+ source : default_hostname ( ) . to_string ( ) ,
161160 datacontenttype : None ,
162161 schemaurl : None ,
163162 subject : None ,
@@ -228,7 +227,7 @@ mod tests {
228227 let a = Attributes {
229228 id : String :: from ( "1" ) ,
230229 ty : String :: from ( "someType" ) ,
231- source : Url :: parse ( "https://example.net" ) . unwrap ( ) ,
230+ source : "https://example.net" . into ( ) ,
232231 datacontenttype : None ,
233232 schemaurl : None ,
234233 subject : None ,
0 commit comments