From 99d0c3fa10e23ab2510e49f530270106f9cdfd8f Mon Sep 17 00:00:00 2001 From: hkohko Date: Wed, 17 Apr 2024 14:48:54 +0700 Subject: [PATCH] fix: collapsed impl and renamed variable --- src/bulk.rs | 54 ++++++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/src/bulk.rs b/src/bulk.rs index 23fda9e..9d21466 100644 --- a/src/bulk.rs +++ b/src/bulk.rs @@ -22,6 +22,30 @@ impl Default for ParallelBuilder { } } impl ParallelBuilder { + /// Builds a new [`Parallel`] with default or specified configuration. + /// # Example + /// This is the minimal requirements for using this method: + /// ``` + /// # fn main() { + /// # use jippigy::Parallel; + /// let mut vector_of_bytes: Vec> = Vec::new(); + /// let _build = Parallel::from_vec(vector_of_bytes).build(); + /// # } + /// ``` + pub fn build(self) -> Parallel { + let (tx, rx) = channel::unbounded(); + Parallel { + main_worker: Worker::new_fifo(), + vec: self.vec, + to_thread: StuffThatNeedsToBeSent { + device_num: self.device_num, + quality: self.quality, + stealers: Vec::with_capacity(usize::from(self.device_num)), + }, + transmitter: tx, + receiver: rx, + } + } /// Specifies the quality of compressed images. /// Defaults to 95 (95% of the original quality). /// @@ -49,32 +73,6 @@ impl ParallelBuilder { } } } -impl ParallelBuilder { - /// Builds a new [`Parallel`] with default or specified configuration. - /// # Example - /// This is the minimal requirements for using this method: - /// ``` - /// # fn main() { - /// # use jippigy::Parallel; - /// let mut vector_of_bytes: Vec> = Vec::new(); - /// let _build = Parallel::from_vec(vector_of_bytes).build(); - /// # } - /// ``` - pub fn build(self) -> Parallel { - let (tx, rx) = channel::unbounded(); - Parallel { - main_worker: Worker::new_fifo(), - vec: self.vec, - to_thread: StuffThatNeedsToBeSent { - device_num: self.device_num, - quality: self.quality, - stealers: Vec::with_capacity(usize::from(self.device_num)), - }, - transmitter: tx, - receiver: rx, - } - } -} #[derive(Debug)] pub struct StuffThatNeedsToBeSent { device_num: u8, @@ -101,10 +99,10 @@ impl StuffThatNeedsToBeSent { continue; }; for stealer in stealer_guard.iter() { - let Steal::Success(direntry) = stealer.steal() else { + let Steal::Success(jpeg_bytes) = stealer.steal() else { continue; }; - payload.push(direntry); + payload.push(jpeg_bytes); break; } let _checks = stealer_guard