Remove Report type in iced_sentinel

This commit is contained in:
Héctor Ramón Jiménez 2024-02-27 14:46:57 +01:00
parent dd36893f7a
commit 7f7c5ea337
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
3 changed files with 9 additions and 15 deletions

View file

@ -44,7 +44,6 @@ mod internal {
use iced_sentinel::client::{self, Client};
use iced_sentinel::timing::{self, Timing};
use iced_sentinel::Report;
use once_cell::sync::Lazy;
use std::sync::{Mutex, MutexGuard};
@ -96,10 +95,10 @@ mod internal {
impl Timer {
pub fn finish(self) {
lock().sentinel.report(Report::Timing(Timing {
lock().sentinel.report_timing(Timing {
stage: self.stage,
duration: self.start.elapsed(),
}));
});
}
}

View file

@ -1,4 +1,4 @@
use crate::{Input, Report, SOCKET_ADDRESS};
use crate::{Input, Timing, SOCKET_ADDRESS};
use tokio::io::{self, AsyncWriteExt};
use tokio::net;
@ -11,8 +11,8 @@ pub struct Client {
}
impl Client {
pub fn report(&mut self, report: Report) {
let _ = self.sender.try_send(Input::Reported(report));
pub fn report_timing(&mut self, timing: Timing) {
let _ = self.sender.try_send(Input::TimingMeasured(timing));
}
}

View file

@ -17,19 +17,14 @@ pub const SOCKET_ADDRESS: &str = "127.0.0.1:9167";
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum Input {
Connected(Version),
Reported(Report),
TimingMeasured(Timing),
}
#[derive(Debug, Clone)]
pub enum Event {
Connected(Version),
Disconnected,
Reported(Report),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum Report {
Timing(Timing),
TimingMeasured(Timing),
}
pub fn run() -> impl Stream<Item = Event> {
@ -89,8 +84,8 @@ async fn receive(
Input::Connected(version) => {
Event::Connected(version)
}
Input::Reported(report) => {
Event::Reported(report)
Input::TimingMeasured(timing) => {
Event::TimingMeasured(timing)
}
},
))