File tree Expand file tree Collapse file tree 7 files changed +19
-15
lines changed
Expand file tree Collapse file tree 7 files changed +19
-15
lines changed Original file line number Diff line number Diff line change @@ -230,7 +230,7 @@ impl Client {
230230 /// # .source("https://www.eventsourcingdb.io".to_string())
231231 /// # .data(json!({"value": 1}))
232232 /// # .subject("/test".to_string())
233- /// # .r#type ("io.eventsourcingdb.test".to_string())
233+ /// # .ty ("io.eventsourcingdb.test".to_string())
234234 /// # .build()
235235 /// # ],
236236 /// # vec![]
@@ -419,7 +419,7 @@ impl Client {
419419 /// .source("https://www.eventsourcingdb.io".to_string())
420420 /// .data(json!({"value": 1}))
421421 /// .subject("/test".to_string())
422- /// .r#type ("io.eventsourcingdb.test".to_string())
422+ /// .ty ("io.eventsourcingdb.test".to_string())
423423 /// .build()
424424 /// ];
425425 /// let written_events = client.write_events(candidates, vec![]).await.expect("Failed to write events");
Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ pub enum BoundType {
6161#[ serde( rename_all = "camelCase" ) ]
6262pub struct Bound < ' a > {
6363 /// The type of the bound
64+ #[ serde( rename = "type" ) ]
6465 pub bound_type : BoundType ,
6566 /// The value of the bound
6667 pub id : & ' a str ,
Original file line number Diff line number Diff line change @@ -20,7 +20,8 @@ pub struct Event {
2020 time : DateTime < Utc > ,
2121 #[ serde( flatten) ]
2222 traceinfo : Option < TraceInfo > ,
23- r#type : String ,
23+ #[ serde( rename = "type" ) ]
24+ ty : String ,
2425}
2526
2627impl Event {
@@ -89,7 +90,7 @@ impl Event {
8990 /// Get the type of an event.
9091 #[ must_use]
9192 pub fn ty ( & self ) -> & str {
92- & self . r#type
93+ & self . ty
9394 }
9495}
9596
@@ -99,7 +100,7 @@ impl From<Event> for EventCandidate {
99100 data : event. data ,
100101 source : event. source ,
101102 subject : event. subject ,
102- r#type : event. r#type ,
103+ ty : event. ty ,
103104 traceinfo : event. traceinfo ,
104105 }
105106 }
@@ -111,7 +112,7 @@ impl From<Event> for cloudevents::Event {
111112 let mut builder = cloudevents:: EventBuilderV10 :: new ( )
112113 . source ( event. source )
113114 . subject ( event. subject )
114- . ty ( event. r#type )
115+ . ty ( event. ty )
115116 . id ( event. id )
116117 . time ( event. time . to_string ( ) )
117118 . data ( event. datacontenttype , event. data ) ;
Original file line number Diff line number Diff line change @@ -26,7 +26,8 @@ pub struct EventCandidate {
2626 /// The type of the event.
2727 /// This has to be a reverse domain name.
2828 #[ builder( setter( into) ) ]
29- pub r#type : String ,
29+ #[ serde( rename = "type" ) ]
30+ pub ty : String ,
3031 /// The traceparent of the event.
3132 /// This is used for distributed tracing.
3233 #[ builder( default , setter( strip_option) ) ]
@@ -52,7 +53,7 @@ impl TryFrom<cloudevents::Event> for EventCandidate {
5253 data,
5354 source : event. source ( ) . to_string ( ) ,
5455 subject,
55- r#type : event. ty ( ) . to_string ( ) ,
56+ ty : event. ty ( ) . to_string ( ) ,
5657 traceinfo,
5758 } )
5859 }
Original file line number Diff line number Diff line change @@ -22,7 +22,8 @@ pub struct ManagementEvent {
2222 specversion : String ,
2323 subject : String ,
2424 time : DateTime < Utc > ,
25- r#type : String ,
25+ #[ serde( rename = "type" ) ]
26+ ty : String ,
2627}
2728
2829impl ManagementEvent {
@@ -68,7 +69,7 @@ impl ManagementEvent {
6869 /// This method is called `ty` to avoid conflicts with the `type` keyword in Rust.
6970 #[ must_use]
7071 pub fn ty ( & self ) -> & str {
71- & self . r#type
72+ & self . ty
7273 }
7374}
7475
@@ -79,7 +80,7 @@ impl From<ManagementEvent> for cloudevents::Event {
7980 cloudevents:: EventBuilderV10 :: new ( )
8081 . source ( event. source )
8182 . subject ( event. subject )
82- . ty ( event. r#type )
83+ . ty ( event. ty )
8384 . id ( event. id )
8485 . time ( event. time . to_string ( ) )
8586 . data ( event. datacontenttype , event. data )
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ pub fn create_test_eventcandidate(
1010 . source ( "https://www.eventsourcingdb.io" . to_string ( ) )
1111 . data ( data. into ( ) )
1212 . subject ( subject. to_string ( ) )
13- . r#type ( "io.eventsourcingdb.test" . to_string ( ) )
13+ . ty ( "io.eventsourcingdb.test" . to_string ( ) )
1414 . build ( )
1515}
1616
@@ -34,7 +34,7 @@ pub fn assert_event_match_eventcandidate(
3434 & event_candidate. subject,
3535 "Subject mismatch"
3636 ) ;
37- assert_eq ! ( event. ty( ) , & event_candidate. r#type , "Type mismatch" ) ;
37+ assert_eq ! ( event. ty( ) , & event_candidate. ty , "Type mismatch" ) ;
3838 assert_eq ! (
3939 event. traceinfo( ) ,
4040 event_candidate. traceinfo. as_ref( ) ,
Original file line number Diff line number Diff line change @@ -280,7 +280,7 @@ async fn write_single_event_with_traceparent() {
280280 . source ( "https://www.eventsourcingdb.io" . to_string ( ) )
281281 . data ( json ! ( { "value" : 1 } ) )
282282 . subject ( "/test" . to_string ( ) )
283- . r#type ( "io.eventsourcingdb.test" . to_string ( ) )
283+ . ty ( "io.eventsourcingdb.test" . to_string ( ) )
284284 . traceinfo ( TraceInfo :: Traceparent {
285285 traceparent : "00-01234567012345670123456701234567-0123456701234567-00" . to_string ( ) ,
286286 } )
@@ -302,7 +302,7 @@ async fn write_single_event_with_traceparent_and_state() {
302302 . source ( "https://www.eventsourcingdb.io" . to_string ( ) )
303303 . data ( json ! ( { "value" : 1 } ) )
304304 . subject ( "/test" . to_string ( ) )
305- . r#type ( "io.eventsourcingdb.test" . to_string ( ) )
305+ . ty ( "io.eventsourcingdb.test" . to_string ( ) )
306306 . traceinfo ( TraceInfo :: WithState {
307307 traceparent : "00-01234567012345670123456701234567-0123456701234567-00" . to_string ( ) ,
308308 tracestate : "state=12345" . to_string ( ) ,
You can’t perform that action at this time.
0 commit comments