Skip to content

Commit

Permalink
Refactor: let the reporter take anything which can be converted into …
Browse files Browse the repository at this point in the history
…an Event instead of a raw event.

Changes API of Reporter::report_event to take an impl Into<Self::Event> instead of an Self::Event, for convenience.
  • Loading branch information
foresterre committed Jun 9, 2022
1 parent 1b143f1 commit fe259af
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self::Event>) -> Result<(), Self::Err>;

/// Request to be disconnected.
///
Expand Down
4 changes: 2 additions & 2 deletions src/reporter/channel_reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ impl<Event> Reporter for ChannelReporter<Event> {
type Event = Event;
type Err = ReporterError<Event>;

fn report_event(&self, event: Self::Event) -> Result<(), Self::Err> {
fn report_event(&self, event: impl Into<Self::Event>) -> Result<(), Self::Err> {
self.message_sender
.send(event)
.send(event.into())
.map_err(ReporterError::SendError)
}

Expand Down

0 comments on commit fe259af

Please sign in to comment.