1
1
use 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 } ;
4
3
use crate :: message:: { BinarySerializer , MessageAttributeValue } ;
5
4
use chrono:: { DateTime , Utc } ;
6
5
use url:: Url ;
@@ -22,7 +21,7 @@ pub(crate) const ATTRIBUTE_NAMES: [&str; 8] = [
22
21
pub struct Attributes {
23
22
pub ( crate ) id : String ,
24
23
pub ( crate ) ty : String ,
25
- pub ( crate ) source : Url ,
24
+ pub ( crate ) source : UriReference ,
26
25
pub ( crate ) datacontenttype : Option < String > ,
27
26
pub ( crate ) schemaurl : Option < Url > ,
28
27
pub ( crate ) subject : Option < String > ,
@@ -64,7 +63,7 @@ impl<'a> Iterator for AttributesIntoIterator<'a> {
64
63
. attributes
65
64
. schemaurl
66
65
. as_ref ( )
67
- . map ( |v| ( "schemaurl" , AttributeValue :: URIRef ( v) ) ) ,
66
+ . map ( |v| ( "schemaurl" , AttributeValue :: URI ( v) ) ) ,
68
67
6 => self
69
68
. attributes
70
69
. subject
@@ -90,7 +89,7 @@ impl AttributesReader for Attributes {
90
89
& self . id
91
90
}
92
91
93
- fn source ( & self ) -> & Url {
92
+ fn source ( & self ) -> & UriReference {
94
93
& self . source
95
94
}
96
95
@@ -124,7 +123,7 @@ impl AttributesWriter for Attributes {
124
123
std:: mem:: replace ( & mut self . id , id. into ( ) )
125
124
}
126
125
127
- fn set_source ( & mut self , source : impl Into < Url > ) -> Url {
126
+ fn set_source ( & mut self , source : impl Into < UriReference > ) -> UriReference {
128
127
std:: mem:: replace ( & mut self . source , source. into ( ) )
129
128
}
130
129
@@ -157,7 +156,7 @@ impl Default for Attributes {
157
156
Attributes {
158
157
id : Uuid :: new_v4 ( ) . to_string ( ) ,
159
158
ty : "type" . to_string ( ) ,
160
- source : default_hostname ( ) ,
159
+ source : default_hostname ( ) . to_string ( ) ,
161
160
datacontenttype : None ,
162
161
schemaurl : None ,
163
162
subject : None ,
@@ -228,7 +227,7 @@ mod tests {
228
227
let a = Attributes {
229
228
id : String :: from ( "1" ) ,
230
229
ty : String :: from ( "someType" ) ,
231
- source : Url :: parse ( "https://example.net" ) . unwrap ( ) ,
230
+ source : "https://example.net" . into ( ) ,
232
231
datacontenttype : None ,
233
232
schemaurl : None ,
234
233
subject : None ,
0 commit comments