/// Applies all pending writes accumulated so far on a data buffer. The pending writes are then
/// cleared.
Applies all pending writes accumulated so far on a data buffer. The pending writes are then
cleared.
Applies all pending writes accumulated so far on a data buffer . The pending writes are then cleared .
fn apply_pending_writes_on_data(&mut self, id: DriveId, data: &mut Vec<u8>) {
        self.pending_writes
            .entry(id.clone())
            .or_insert(Vec::new())
            .iter()
            .filter(|write| write.id == id)
            .for_each(|pending_write| {
                debug!(
                    "Applying pending write with offset {} on {}",
                    &pending_write.offset, &pending_write.id
                );
                let required_size = pending_write.offset + pending_write.data.len();
                data.resize(required_size, 0);
                data[pending_write.offset..].copy_from_slice(&pending_write.data[..]);
            });
        self.pending_writes.remove(&id);
    }
fn apply_pending_writes_on_data ( & mut self , id : DriveId , data : & mut Vec < u8 > ) { self . pending_writes . entry ( id . clone ( ) ) . or_insert ( Vec :: new ( ) ) . iter ( ) . filter ( | write | write . id == id ) . for_each ( | pending_write | { debug ! ( " " pending_write offset pending_write id ) ; let required_size = pending_write . offset + pending_write . data . len ( ) ; data . resize ( required_size , 0 ) ; data [ pending_write . offset .. ] . copy_from_slice ( & pending_write . data [ .. ] ) ; } ) ; self . pending_writes . remove ( & id ) ; }
Applies all pending writes accumulated so far on a data buffer.
Applies all pending writes accumulated so far on a data buffer .
&mut self
id
DriveId
data
&mut Vec<u8>