Skip to content

Commit

Permalink
fix: collapsed impl and renamed variable
Browse files Browse the repository at this point in the history
  • Loading branch information
rfdzan committed Apr 17, 2024
1 parent 45b156e commit 99d0c3f
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions src/bulk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>> = 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).
///
Expand Down Expand Up @@ -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<u8>> = 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,
Expand All @@ -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
Expand Down

0 comments on commit 99d0c3f

Please sign in to comment.