33mod attributes;
44mod builder;
55mod data;
6- mod displayerr;
7- mod event;
86mod extensions;
97#[ macro_use]
108mod format;
@@ -17,8 +15,6 @@ pub use attributes::{AttributeValue, AttributesReader, AttributesWriter};
1715pub use builder:: Error as EventBuilderError ;
1816pub use builder:: EventBuilder ;
1917pub use data:: Data ;
20- pub use displayerr:: DisplayError ;
21- pub use event:: Event ;
2218pub use extensions:: ExtensionValue ;
2319pub ( crate ) use message:: EventBinarySerializer ;
2420pub ( crate ) use message:: EventStructuredSerializer ;
@@ -45,9 +41,11 @@ pub(crate) use v10::EventFormatSerializer as EventFormatSerializerV10;
4541use chrono:: { DateTime , Utc } ;
4642use delegate_attr:: delegate;
4743use std:: collections:: HashMap ;
48- use std:: fmt;
44+ //use std::fmt;
45+ use std:: prelude:: v1:: * ;
4946use url:: Url ;
5047
48+ use core:: fmt:: { self , Debug , Display } ;
5149/// Data structure that represents a [CloudEvent](https://github.com/cloudevents/spec/blob/master/spec.md).
5250/// It provides methods to get the attributes through [`AttributesReader`]
5351/// and write them through [`AttributesWriter`].
@@ -239,6 +237,32 @@ impl Event {
239237 }
240238}
241239
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+
242266#[ cfg( test) ]
243267mod tests {
244268 use super :: * ;
0 commit comments