Clippy cleanup
This commit is contained in:
@@ -180,9 +180,7 @@ impl StreamLine {
|
||||
let input = self.line.as_str();
|
||||
let re = Regex::new(r"\[(.*?)\]").unwrap();
|
||||
let time_s = re.captures(input).map(|v| v[1].to_string());
|
||||
if time_s.is_none() {
|
||||
return None;
|
||||
}
|
||||
time_s.as_ref()?;
|
||||
let time = NaiveTime::parse_from_str(&time_s.unwrap(), "%H:%M:%S").ok()?;
|
||||
|
||||
let today = Local::now().date_naive();
|
||||
@@ -233,19 +231,18 @@ impl Display for InstanceEvent {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let head = format!(
|
||||
"UUID: {}\nTimestamp:{}\nPayload:\n",
|
||||
self.id.to_string(),
|
||||
self.timestamp.to_string()
|
||||
self.id, self.timestamp
|
||||
);
|
||||
match self.payload.clone() {
|
||||
EventPayload::StdLine { line } => {
|
||||
let full = format!("{}{}", head, line);
|
||||
write!(f, "{}\n", full)
|
||||
writeln!(f, "{}", full)
|
||||
}
|
||||
|
||||
#[cfg(feature = "events")]
|
||||
EventPayload::StateChange { old, new } => {
|
||||
let full = format!("{}State changed: {:?} -> {:?}", head, old, new);
|
||||
write!(f, "{}\n", full)
|
||||
writeln!(f, "{}", full)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ use uuid::Uuid;
|
||||
#[cfg(feature = "events")]
|
||||
use crate::config::stream::InstanceEvent;
|
||||
use crate::{
|
||||
config::{MinecraftType, MinecraftVersion, StreamLine, StreamSource, stream::EventPayload},
|
||||
config::{MinecraftType, MinecraftVersion, StreamSource, stream::EventPayload},
|
||||
error::{HandleError, ServerError, SubscribeError},
|
||||
};
|
||||
|
||||
@@ -319,11 +319,8 @@ impl InstanceHandle {
|
||||
}
|
||||
|
||||
maybe_event = internal_rx.recv() => {
|
||||
match maybe_event {
|
||||
Some(event) => {
|
||||
println!("event: {}", event);
|
||||
}
|
||||
_ => (),
|
||||
if let Some(event) = maybe_event {
|
||||
println!("event: {}", event);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -362,7 +359,7 @@ impl InstanceHandle {
|
||||
child.kill().await.map_err(|_| ServerError::CommandFailed)?;
|
||||
|
||||
self.transition_status(InstanceStatus::Killed).await;
|
||||
sleep(Duration::from_secs(1));
|
||||
sleep(Duration::from_secs(1)).await;
|
||||
self.shutdown.cancel();
|
||||
self.child = None;
|
||||
Ok(())
|
||||
@@ -380,7 +377,7 @@ impl InstanceHandle {
|
||||
child.wait().await.map_err(|_| ServerError::CommandFailed)?;
|
||||
|
||||
self.transition_status(InstanceStatus::Stopped).await;
|
||||
sleep(Duration::from_secs(1));
|
||||
sleep(Duration::from_secs(1)).await;
|
||||
self.shutdown.cancel();
|
||||
self.child = None;
|
||||
Ok(())
|
||||
|
||||
@@ -4,9 +4,7 @@ use regex::Regex;
|
||||
pub fn extract_timestamp(input: &str) -> Option<DateTime<Utc>> {
|
||||
let re = Regex::new(r"\[(.*?)\]").unwrap();
|
||||
let time_s = re.captures(input).map(|v| v[1].to_string());
|
||||
if time_s.is_none() {
|
||||
return None;
|
||||
}
|
||||
time_s.as_ref()?;
|
||||
let time = NaiveTime::parse_from_str(&time_s.unwrap(), "%H:%M:%S").ok()?;
|
||||
|
||||
let today = Local::now().date_naive();
|
||||
|
||||
Reference in New Issue
Block a user