|
|
|
@ -2,12 +2,19 @@ use super::*;
|
|
|
|
|
use job::Job;
|
|
|
|
|
use std::io::Read;
|
|
|
|
|
|
|
|
|
|
pub fn work_on(job: &mut Job) -> Result<(), Box<dyn std::error::Error>>
|
|
|
|
|
pub fn work_on(job: &mut Job) -> Result<usize, Box<dyn std::error::Error>>
|
|
|
|
|
{
|
|
|
|
|
let output = job.output_slice();
|
|
|
|
|
let mut buf = [0u8; 4096];
|
|
|
|
|
while let Ok(read) = job.read(&mut buf) {
|
|
|
|
|
//TODO: copy from `job`'s file into `output`.
|
|
|
|
|
let output = unsafe {
|
|
|
|
|
// Required because the compiler thinks we're mutably borrowing the same data later on, even though they are unrelated fields of the struct
|
|
|
|
|
std::slice::from_raw_parts_mut(output.as_mut_ptr(), output.len())
|
|
|
|
|
};
|
|
|
|
|
let mut read=0;
|
|
|
|
|
loop {
|
|
|
|
|
match job.read(&mut output[read..])? {
|
|
|
|
|
0 => break,
|
|
|
|
|
current => read+=current,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
todo!()
|
|
|
|
|
Ok(read)
|
|
|
|
|
}
|
|
|
|
|