From fe259af5e7f21b7b887d7947cbde5dfa961dc44a Mon Sep 17 00:00:00 2001 From: Martijn Gribnau Date: Thu, 9 Jun 2022 18:43:23 +0200 Subject: [PATCH] Refactor: let the reporter take anything which can be converted into an Event instead of a raw event. Changes API of Reporter::report_event to take an impl Into instead of an Self::Event, for convenience. --- src/reporter.rs | 2 +- src/reporter/channel_reporter.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/reporter.rs b/src/reporter.rs index f7d8612..bcca601 100644 --- a/src/reporter.rs +++ b/src/reporter.rs @@ -12,7 +12,7 @@ pub trait Reporter { type Err; /// Send an event to listeners. - fn report_event(&self, event: Self::Event) -> Result<(), Self::Err>; + fn report_event(&self, event: impl Into) -> Result<(), Self::Err>; /// Request to be disconnected. /// diff --git a/src/reporter/channel_reporter.rs b/src/reporter/channel_reporter.rs index 0716f68..10ca609 100644 --- a/src/reporter/channel_reporter.rs +++ b/src/reporter/channel_reporter.rs @@ -40,9 +40,9 @@ impl Reporter for ChannelReporter { type Event = Event; type Err = ReporterError; - fn report_event(&self, event: Self::Event) -> Result<(), Self::Err> { + fn report_event(&self, event: impl Into) -> Result<(), Self::Err> { self.message_sender - .send(event) + .send(event.into()) .map_err(ReporterError::SendError) }