Skip to content

Commit

Permalink
Cargo clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
connorslade committed Sep 7, 2024
1 parent d4097e5 commit d4fecc8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
6 changes: 1 addition & 5 deletions lib/extensions/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,7 @@ impl Logger {
pub fn file(self, file: impl AsRef<Path>) -> io::Result<Self> {
Ok(Self {
file: Some(Mutex::new(
OpenOptions::new()
.create(true)
.write(true)
.append(true)
.open(file)?,
OpenOptions::new().create(true).append(true).open(file)?,
)),
..self
})
Expand Down
2 changes: 2 additions & 0 deletions lib/internal/nonblocking/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Utilities for non-blocking I/O.
use std::{
io,
net::{SocketAddr, TcpStream},
Expand Down
20 changes: 9 additions & 11 deletions lib/proto/server_sent_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
//! });
//! ```
use std::{
fmt::Display,
io::Write,
fmt::{self, Display, Write},
sync::{
atomic::{AtomicBool, Ordering},
mpsc::{self, Sender},
Expand Down Expand Up @@ -174,23 +173,22 @@ impl Event {
}
}

impl ToString for Event {
fn to_string(&self) -> String {
let mut out = String::new();

impl Display for Event {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(id) = self.id {
out.push_str(&format!("id: {id}\n"));
f.write_fmt(format_args!("id: {id}\n"))?;
}

let event = &self.event;
out.push_str(&format!("event: {event}\n"));
f.write_fmt(format_args!("event: {event}\n"))?;

for i in self.data.split('\n') {
out.push_str(&format!("data: {i}\n"));
f.write_fmt(format_args!("data: {i}\n"))?;
}

out.push('\n');
out
f.write_char('\n')?;

Ok(())
}
}

Expand Down
3 changes: 2 additions & 1 deletion lib/server.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
any::type_name,
net::{IpAddr, SocketAddr, TcpStream},
net::{IpAddr, SocketAddr},
str,
sync::{
atomic::{AtomicBool, Ordering},
Expand Down Expand Up @@ -165,6 +165,7 @@ impl<State: Send + Sync> Server<State> {
Ok(())
}

/// Starts the server on a separate thread, retuning a handle that allows you to retrieve the server state and shutdown the server.
pub fn run_async(mut self) -> Result<ServerHandle<State>> {
self.checks()?;

Expand Down

0 comments on commit d4fecc8

Please sign in to comment.