|
|
@ -2,12 +2,19 @@ use super::*;
|
|
|
|
use job::Job;
|
|
|
|
use job::Job;
|
|
|
|
use std::io::Read;
|
|
|
|
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 output = job.output_slice();
|
|
|
|
let mut buf = [0u8; 4096];
|
|
|
|
let output = unsafe {
|
|
|
|
while let Ok(read) = job.read(&mut buf) {
|
|
|
|
// Required because the compiler thinks we're mutably borrowing the same data later on, even though they are unrelated fields of the struct
|
|
|
|
//TODO: copy from `job`'s file into `output`.
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|