/// Flushes any outstanding complete blocks to the journal object.  Part blocks can be flushed
/// by calling pad_to_block first.  Does nothing if no handle has been set yet.
Flushes any outstanding complete blocks to the journal object.  Part blocks can be flushed
by calling pad_to_block first.  Does nothing if no handle has been set yet.
Flushes any outstanding complete blocks to the journal object . Part blocks can be flushed by calling pad_to_block first . Does nothing if no handle has been set yet .
pub async fn maybe_flush_buffer(&mut self) -> Result<(), Error>
    where
        OH: ObjectHandle,
    {
        if let Some(ref handle) = self.handle {
            let to_do = self.buf.len() - self.buf.len() % self.block_size;
            if to_do > 0 {
                // TODO(jfsulliv): This is horribly inefficient. We should reuse the transfer
                // buffer. Doing so will require picking an appropriate size up front, and forcing
                // flush as we fill it up.
                let mut buf = handle.allocate_buffer(to_do);
                buf.as_mut_slice()[..to_do].copy_from_slice(self.buf.drain(..to_do).as_slice());
                buf.as_mut_slice()[to_do..].fill(0u8);
                handle.write(self.offset, buf.as_ref()).await?;
                self.offset += to_do as u64;
            }
        }
        Ok(())
    }
pub async fn maybe_flush_buffer ( & mut self ) -> Result < ( ) , Error > where OH : ObjectHandle , { if let Some ( ref handle ) = self . handle { let to_do = self . buf . len ( ) - self . buf . len ( ) % self . block_size ; if to_do > 0 { // TODO(jfsulliv): This is horribly inefficient. We should reuse the transfer // buffer. Doing so will require picking an appropriate size up front, and forcing // flush as we fill it up. let mut buf = handle . allocate_buffer ( to_do ) ; buf . as_mut_slice ( ) [ .. to_do ] . copy_from_slice ( self . buf . drain ( .. to_do ) . as_slice ( ) ) ; buf . as_mut_slice ( ) [ to_do .. ] . fill ( 0u8 ) ; handle . write ( self . offset , buf . as_ref ( ) ) . await ? ; self . offset += to_do as u64 ; } } Ok ( ( ) ) }
Flushes any outstanding complete blocks to the journal object.
Flushes any outstanding complete blocks to the journal object .
&mut self