Skip to content

Commit e652e12

Browse files
committed
rebased
Signed-off-by: [email protected] <[email protected]>
1 parent cbd9934 commit e652e12

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

Diff for: src/event/displayerr.rs

-24
This file was deleted.

Diff for: src/event/mod.rs

+29-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
mod attributes;
44
mod builder;
55
mod data;
6-
mod displayerr;
7-
mod event;
86
mod extensions;
97
#[macro_use]
108
mod format;
@@ -17,8 +15,6 @@ pub use attributes::{AttributeValue, AttributesReader, AttributesWriter};
1715
pub use builder::Error as EventBuilderError;
1816
pub use builder::EventBuilder;
1917
pub use data::Data;
20-
pub use displayerr::DisplayError;
21-
pub use event::Event;
2218
pub use extensions::ExtensionValue;
2319
pub(crate) use message::EventBinarySerializer;
2420
pub(crate) use message::EventStructuredSerializer;
@@ -45,9 +41,11 @@ pub(crate) use v10::EventFormatSerializer as EventFormatSerializerV10;
4541
use chrono::{DateTime, Utc};
4642
use delegate_attr::delegate;
4743
use std::collections::HashMap;
48-
use std::fmt;
44+
//use std::fmt;
45+
use std::prelude::v1::*;
4946
use 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)]
243267
mod tests {
244268
use super::*;

0 commit comments

Comments
 (0)