pub fn pwrite_all_fallible(fd: i32, buf_initial: &[u8], offset: isize) -> Result<usize, ()> {
    let mut written: usize = 0;
    let mut cur_size = buf_initial.len();

    let mut buf = buf_initial;
    while cur_size > 0 {
        let ret: isize =
            unsafe { pwrite64(fd, buf.as_ptr().cast::<c_void>(), cur_size, offset as i64) };

        if written > 0 && ret <= 0 {
            return Ok(written);
        } else if written == 0 && ret == 0 {
            return Ok(written);
        } else if ret < 0 {
            return Err(());
        } else {
            // We know that ret > 0 by now so its safe to cast ret as usize in this block.
            buf = &buf[ret as usize..];
            written += ret as usize;
            cur_size -= ret as usize;
        }
    }

    Ok(written)
}
/// Like pwrite64(2) but we try to write all bytes by looping on short writes.
///
/// Slightly different from rr. Employs Result.
Like pwrite64(2) but we try to write all bytes by looping on short writes.
Slightly different from rr. Employs Result.
Like pwrite64 ( 2 ) but we try to write all bytes by looping on short writes . Slightly different from rr . Employs Result .
pub fn pwrite_all_fallible(fd: i32, buf_initial: &[u8], offset: isize) -> Result<usize, ()> {
    let mut written: usize = 0;
    let mut cur_size = buf_initial.len();
    let mut buf = buf_initial;
    while cur_size > 0 {
        let ret: isize =
            unsafe { pwrite64(fd, buf.as_ptr().cast::<c_void>(), cur_size, offset as i64) };
        if written > 0 && ret <= 0 {
            return Ok(written);
        } else if written == 0 && ret == 0 {
            return Ok(written);
        } else if ret < 0 {
            return Err(());
        } else {
            // We know that ret > 0 by now so its safe to cast ret as usize in this block.
            buf = &buf[ret as usize..];
            written += ret as usize;
            cur_size -= ret as usize;
        }
    }
    Ok(written)
}
pub fn pwrite_all_fallible ( fd : i32 , buf_initial : & [ u8 ] , offset : isize ) -> Result < usize , ( ) > { let mut written : usize = 0 ; let mut cur_size = buf_initial . len ( ) ; let mut buf = buf_initial ; while cur_size > 0 { let ret : isize = unsafe { pwrite64 ( fd , buf . as_ptr ( ) . cast :: < c_void > ( ) , cur_size , offset as i64 ) } ; if written > 0 && ret <= 0 { return Ok ( written ) ; } else if written == 0 && ret == 0 { return Ok ( written ) ; } else if ret < 0 { return Err ( ( ) ) ; } else { // We know that ret > 0 by now so its safe to cast ret as usize in this block. buf = & buf [ ret as usize .. ] ; written += ret as usize ; cur_size -= ret as usize ; } } Ok ( written ) }
Like pwrite64(2) but we try to write all bytes by looping on short writes.
Like pwrite64 ( 2 ) but we try to write all bytes by looping on short writes .
fd
i32
buf_initial
&[u8]
offset
isize