3
3
mod attributes;
4
4
mod builder;
5
5
mod data;
6
- mod displayerr;
7
- mod event;
8
6
mod extensions;
9
7
#[ macro_use]
10
8
mod format;
@@ -17,8 +15,6 @@ pub use attributes::{AttributeValue, AttributesReader, AttributesWriter};
17
15
pub use builder:: Error as EventBuilderError ;
18
16
pub use builder:: EventBuilder ;
19
17
pub use data:: Data ;
20
- pub use displayerr:: DisplayError ;
21
- pub use event:: Event ;
22
18
pub use extensions:: ExtensionValue ;
23
19
pub ( crate ) use message:: EventBinarySerializer ;
24
20
pub ( crate ) use message:: EventStructuredSerializer ;
@@ -45,9 +41,11 @@ pub(crate) use v10::EventFormatSerializer as EventFormatSerializerV10;
45
41
use chrono:: { DateTime , Utc } ;
46
42
use delegate_attr:: delegate;
47
43
use std:: collections:: HashMap ;
48
- use std:: fmt;
44
+ //use std::fmt;
45
+ use std:: prelude:: v1:: * ;
49
46
use url:: Url ;
50
47
48
+ use core:: fmt:: { self , Debug , Display } ;
51
49
/// Data structure that represents a [CloudEvent](https://github.com/cloudevents/spec/blob/master/spec.md).
52
50
/// It provides methods to get the attributes through [`AttributesReader`]
53
51
/// and write them through [`AttributesWriter`].
@@ -239,6 +237,32 @@ impl Event {
239
237
}
240
238
}
241
239
240
+ // Facilitates compatibility with snafu::Error for external objects
241
+
242
+ #[ derive( PartialEq , Eq , Clone ) ]
243
+ pub struct DisplayError < T > ( pub T ) ;
244
+
245
+ impl < T > Debug for DisplayError < T >
246
+ where
247
+ T : Debug ,
248
+ {
249
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
250
+ self . 0 . fmt ( f)
251
+ }
252
+ }
253
+
254
+ impl < T > Display for DisplayError < T >
255
+ where
256
+ T : Display ,
257
+ {
258
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
259
+ self . 0 . fmt ( f)
260
+ }
261
+ }
262
+
263
+ impl < T > snafu:: Error for DisplayError < T > where T : Display + Debug { }
264
+
265
+
242
266
#[ cfg( test) ]
243
267
mod tests {
244
268
use super :: * ;
0 commit comments