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 {
230
230
/// # .source("https://www.eventsourcingdb.io".to_string())
231
231
/// # .data(json!({"value": 1}))
232
232
/// # .subject("/test".to_string())
233
- /// # .r#type ("io.eventsourcingdb.test".to_string())
233
+ /// # .ty ("io.eventsourcingdb.test".to_string())
234
234
/// # .build()
235
235
/// # ],
236
236
/// # vec![]
@@ -419,7 +419,7 @@ impl Client {
419
419
/// .source("https://www.eventsourcingdb.io".to_string())
420
420
/// .data(json!({"value": 1}))
421
421
/// .subject("/test".to_string())
422
- /// .r#type ("io.eventsourcingdb.test".to_string())
422
+ /// .ty ("io.eventsourcingdb.test".to_string())
423
423
/// .build()
424
424
/// ];
425
425
/// 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 {
61
61
#[ serde( rename_all = "camelCase" ) ]
62
62
pub struct Bound < ' a > {
63
63
/// The type of the bound
64
+ #[ serde( rename = "type" ) ]
64
65
pub bound_type : BoundType ,
65
66
/// The value of the bound
66
67
pub id : & ' a str ,
Original file line number Diff line number Diff line change @@ -20,7 +20,8 @@ pub struct Event {
20
20
time : DateTime < Utc > ,
21
21
#[ serde( flatten) ]
22
22
traceinfo : Option < TraceInfo > ,
23
- r#type : String ,
23
+ #[ serde( rename = "type" ) ]
24
+ ty : String ,
24
25
}
25
26
26
27
impl Event {
@@ -89,7 +90,7 @@ impl Event {
89
90
/// Get the type of an event.
90
91
#[ must_use]
91
92
pub fn ty ( & self ) -> & str {
92
- & self . r#type
93
+ & self . ty
93
94
}
94
95
}
95
96
@@ -99,7 +100,7 @@ impl From<Event> for EventCandidate {
99
100
data : event. data ,
100
101
source : event. source ,
101
102
subject : event. subject ,
102
- r#type : event. r#type ,
103
+ ty : event. ty ,
103
104
traceinfo : event. traceinfo ,
104
105
}
105
106
}
@@ -111,7 +112,7 @@ impl From<Event> for cloudevents::Event {
111
112
let mut builder = cloudevents:: EventBuilderV10 :: new ( )
112
113
. source ( event. source )
113
114
. subject ( event. subject )
114
- . ty ( event. r#type )
115
+ . ty ( event. ty )
115
116
. id ( event. id )
116
117
. time ( event. time . to_string ( ) )
117
118
. data ( event. datacontenttype , event. data ) ;
Original file line number Diff line number Diff line change @@ -26,7 +26,8 @@ pub struct EventCandidate {
26
26
/// The type of the event.
27
27
/// This has to be a reverse domain name.
28
28
#[ builder( setter( into) ) ]
29
- pub r#type : String ,
29
+ #[ serde( rename = "type" ) ]
30
+ pub ty : String ,
30
31
/// The traceparent of the event.
31
32
/// This is used for distributed tracing.
32
33
#[ builder( default , setter( strip_option) ) ]
@@ -52,7 +53,7 @@ impl TryFrom<cloudevents::Event> for EventCandidate {
52
53
data,
53
54
source : event. source ( ) . to_string ( ) ,
54
55
subject,
55
- r#type : event. ty ( ) . to_string ( ) ,
56
+ ty : event. ty ( ) . to_string ( ) ,
56
57
traceinfo,
57
58
} )
58
59
}
Original file line number Diff line number Diff line change @@ -22,7 +22,8 @@ pub struct ManagementEvent {
22
22
specversion : String ,
23
23
subject : String ,
24
24
time : DateTime < Utc > ,
25
- r#type : String ,
25
+ #[ serde( rename = "type" ) ]
26
+ ty : String ,
26
27
}
27
28
28
29
impl ManagementEvent {
@@ -68,7 +69,7 @@ impl ManagementEvent {
68
69
/// This method is called `ty` to avoid conflicts with the `type` keyword in Rust.
69
70
#[ must_use]
70
71
pub fn ty ( & self ) -> & str {
71
- & self . r#type
72
+ & self . ty
72
73
}
73
74
}
74
75
@@ -79,7 +80,7 @@ impl From<ManagementEvent> for cloudevents::Event {
79
80
cloudevents:: EventBuilderV10 :: new ( )
80
81
. source ( event. source )
81
82
. subject ( event. subject )
82
- . ty ( event. r#type )
83
+ . ty ( event. ty )
83
84
. id ( event. id )
84
85
. time ( event. time . to_string ( ) )
85
86
. data ( event. datacontenttype , event. data )
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ pub fn create_test_eventcandidate(
10
10
. source ( "https://www.eventsourcingdb.io" . to_string ( ) )
11
11
. data ( data. into ( ) )
12
12
. subject ( subject. to_string ( ) )
13
- . r#type ( "io.eventsourcingdb.test" . to_string ( ) )
13
+ . ty ( "io.eventsourcingdb.test" . to_string ( ) )
14
14
. build ( )
15
15
}
16
16
@@ -34,7 +34,7 @@ pub fn assert_event_match_eventcandidate(
34
34
& event_candidate. subject,
35
35
"Subject mismatch"
36
36
) ;
37
- assert_eq ! ( event. ty( ) , & event_candidate. r#type , "Type mismatch" ) ;
37
+ assert_eq ! ( event. ty( ) , & event_candidate. ty , "Type mismatch" ) ;
38
38
assert_eq ! (
39
39
event. traceinfo( ) ,
40
40
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() {
280
280
. source ( "https://www.eventsourcingdb.io" . to_string ( ) )
281
281
. data ( json ! ( { "value" : 1 } ) )
282
282
. subject ( "/test" . to_string ( ) )
283
- . r#type ( "io.eventsourcingdb.test" . to_string ( ) )
283
+ . ty ( "io.eventsourcingdb.test" . to_string ( ) )
284
284
. traceinfo ( TraceInfo :: Traceparent {
285
285
traceparent : "00-01234567012345670123456701234567-0123456701234567-00" . to_string ( ) ,
286
286
} )
@@ -302,7 +302,7 @@ async fn write_single_event_with_traceparent_and_state() {
302
302
. source ( "https://www.eventsourcingdb.io" . to_string ( ) )
303
303
. data ( json ! ( { "value" : 1 } ) )
304
304
. subject ( "/test" . to_string ( ) )
305
- . r#type ( "io.eventsourcingdb.test" . to_string ( ) )
305
+ . ty ( "io.eventsourcingdb.test" . to_string ( ) )
306
306
. traceinfo ( TraceInfo :: WithState {
307
307
traceparent : "00-01234567012345670123456701234567-0123456701234567-00" . to_string ( ) ,
308
308
tracestate : "state=12345" . to_string ( ) ,
You can’t perform that action at this time.
0 commit comments