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