From 829d069e1075f148b51fc3a0391e8615a74b8483 Mon Sep 17 00:00:00 2001 From: Pavel Mikhalkevich Date: Mon, 25 Dec 2023 22:17:25 +0500 Subject: [PATCH] Use W:Write generic in FaktoryCommand --- src/proto/single/cmd.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/proto/single/cmd.rs b/src/proto/single/cmd.rs index d592cd91..160a2776 100644 --- a/src/proto/single/cmd.rs +++ b/src/proto/single/cmd.rs @@ -3,12 +3,12 @@ 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 W) -> 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 W, queues: &[S]) -> Result<(), Error> where W: Write, S: AsRef, @@ -26,7 +26,7 @@ where pub struct Info; impl FaktoryCommand for Info { - fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { + fn issue(&self, w: &mut W) -> Result<(), Error> { Ok(w.write_all(b"INFO\r\n")?) } } @@ -40,7 +40,7 @@ pub struct Ack { } impl FaktoryCommand for Ack { - fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { + fn issue(&self, w: &mut W) -> 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 +63,7 @@ pub struct Heartbeat { } impl FaktoryCommand for Heartbeat { - fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { + fn issue(&self, w: &mut W) -> 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 +90,7 @@ pub struct Fail { } impl FaktoryCommand for Fail { - fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { + fn issue(&self, w: &mut W) -> 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 +121,7 @@ impl Fail { pub struct End; impl FaktoryCommand for End { - fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { + fn issue(&self, w: &mut W) -> Result<(), Error> { Ok(w.write_all(b"END\r\n")?) } } @@ -139,7 +139,7 @@ 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 W) -> Result<(), Error> { if self.queues.is_empty() { w.write_all(b"FETCH\r\n")?; } else { @@ -210,7 +210,7 @@ impl Hello { } impl FaktoryCommand for Hello { - fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { + fn issue(&self, w: &mut W) -> 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 +236,7 @@ impl From for Push { } impl FaktoryCommand for Push { - fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { + fn issue(&self, w: &mut W) -> 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,7 +259,7 @@ where } impl> FaktoryCommand for QueueControl<'_, S> { - fn issue(&self, w: &mut dyn Write) -> Result<(), Error> { + fn issue(&self, w: &mut W) -> Result<(), Error> { let command = match self.action { QueueAction::Pause => b"QUEUE PAUSE".as_ref(), QueueAction::Resume => b"QUEUE RESUME".as_ref(),