From 2bc32716a7a62de662451fdb7c727480147c3a91 Mon Sep 17 00:00:00 2001 From: Pavel Mikhalkevich Date: Mon, 25 Dec 2023 22:06:15 +0500 Subject: [PATCH] Rm unused type param 'W' for writer --- src/proto/single/cmd.rs | 27 +++++++++++++-------------- src/proto/single/mod.rs | 2 +- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/proto/single/cmd.rs b/src/proto/single/cmd.rs index d592cd91..c35a6fdf 100644 --- a/src/proto/single/cmd.rs +++ b/src/proto/single/cmd.rs @@ -3,14 +3,13 @@ use crate::{error::Error, Job}; use std::io::prelude::*; pub trait FaktoryCommand { - fn issue(&self, w: &mut dyn Write) -> Result<(), Error>; + fn issue(&self, w: &mut dyn Write) -> Result<(), Error>; } /// Write queues as part of a command. They are written with a leading space /// followed by space separated queue names. -fn write_queues(w: &mut dyn Write, queues: &[S]) -> Result<(), Error> +fn write_queues(w: &mut dyn Write, queues: &[S]) -> Result<(), Error> where - W: Write, S: AsRef, { for q in queues { @@ -26,7 +25,7 @@ where pub struct Info; impl FaktoryCommand for Info { - fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { + fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { Ok(w.write_all(b"INFO\r\n")?) } } @@ -40,7 +39,7 @@ pub struct Ack { } impl FaktoryCommand for Ack { - fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { + fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { w.write_all(b"ACK ")?; serde_json::to_writer(&mut *w, self).map_err(Error::Serialization)?; Ok(w.write_all(b"\r\n")?) @@ -63,7 +62,7 @@ pub struct Heartbeat { } impl FaktoryCommand for Heartbeat { - fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { + fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { w.write_all(b"BEAT ")?; serde_json::to_writer(&mut *w, self).map_err(Error::Serialization)?; Ok(w.write_all(b"\r\n")?) @@ -90,7 +89,7 @@ pub struct Fail { } impl FaktoryCommand for Fail { - fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { + fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { w.write_all(b"FAIL ")?; serde_json::to_writer(&mut *w, self).map_err(Error::Serialization)?; Ok(w.write_all(b"\r\n")?) @@ -121,7 +120,7 @@ impl Fail { pub struct End; impl FaktoryCommand for End { - fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { + fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { Ok(w.write_all(b"END\r\n")?) } } @@ -139,12 +138,12 @@ impl<'a, S> FaktoryCommand for Fetch<'a, S> where S: AsRef, { - fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { + fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { if self.queues.is_empty() { w.write_all(b"FETCH\r\n")?; } else { w.write_all(b"FETCH")?; - write_queues::(w, self.queues)?; + write_queues::<_>(w, self.queues)?; w.write_all(b"\r\n")?; } Ok(()) @@ -210,7 +209,7 @@ impl Hello { } impl FaktoryCommand for Hello { - fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { + fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { w.write_all(b"HELLO ")?; serde_json::to_writer(&mut *w, self).map_err(Error::Serialization)?; Ok(w.write_all(b"\r\n")?) @@ -236,7 +235,7 @@ impl From for Push { } impl FaktoryCommand for Push { - fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { + fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { w.write_all(b"PUSH ")?; serde_json::to_writer(&mut *w, &**self).map_err(Error::Serialization)?; Ok(w.write_all(b"\r\n")?) @@ -259,14 +258,14 @@ where } impl> FaktoryCommand for QueueControl<'_, S> { - fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { + fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { let command = match self.action { QueueAction::Pause => b"QUEUE PAUSE".as_ref(), QueueAction::Resume => b"QUEUE RESUME".as_ref(), }; w.write_all(command)?; - write_queues::(w, self.queues)?; + write_queues::<_>(w, self.queues)?; Ok(w.write_all(b"\r\n")?) } } diff --git a/src/proto/single/mod.rs b/src/proto/single/mod.rs index 9eca8d8e..e779fea4 100644 --- a/src/proto/single/mod.rs +++ b/src/proto/single/mod.rs @@ -164,7 +164,7 @@ impl Job { } pub fn write_command(w: &mut W, command: &C) -> Result<(), Error> { - command.issue::(w)?; + command.issue(w)?; Ok(w.flush()?) }