async fn overwrite(&self, mut offset: u64, buf: BufferRef<'_>) -> Result<(), Error> {
        let tree = &self.store.tree;
        let layer_set = tree.layer_set();
        let mut merger = layer_set.merger();
        let end = offset + buf.len() as u64;
        let mut iter = merger
            .seek(Bound::Included(
                &ObjectKey::extent(self.object_id, self.attribute_id, offset..end).search_key(),
            ))
            .await?;
        let mut pos = 0;
        loop {
            let (device_offset, to_do) = match iter.get() {
                Some(ItemRef {
                    key:
                        ObjectKey { object_id, data: ObjectKeyData::Extent(ExtentKey { range, .. }) },
                    value: ObjectValue::Extent(ExtentValue { device_offset: Some(device_offset) }),
                }) if *object_id == self.object_id && range.start <= offset => (
                    device_offset + (offset - range.start),
                    min(buf.len() - pos, (range.end - offset) as usize),
                ),
                _ => bail!("offset {} not allocated", offset),
            };
            self.write_at(offset, buf.subslice(pos..pos + to_do), device_offset).await?;
            pos += to_do;
            if pos == buf.len() {
                break;
            }
            offset += to_do as u64;
            iter.advance_with_hint(
                &ObjectKey::extent(self.object_id, self.attribute_id, offset..end).search_key(),
            )
            .await?;
        }
        Ok(())
    }
// All the extents for the range must have been preallocated using preallocate_range or from
// existing writes.
All the extents for the range must have been preallocated using preallocate_range or from
existing writes.
All the extents for the range must have been preallocated using preallocate_range or from existing writes .
async fn overwrite(&self, mut offset: u64, buf: BufferRef<'_>) -> Result<(), Error> {
        let tree = &self.store.tree;
        let layer_set = tree.layer_set();
        let mut merger = layer_set.merger();
        let end = offset + buf.len() as u64;
        let mut iter = merger
            .seek(Bound::Included(
                &ObjectKey::extent(self.object_id, self.attribute_id, offset..end).search_key(),
            ))
            .await?;
        let mut pos = 0;
        loop {
            let (device_offset, to_do) = match iter.get() {
                Some(ItemRef {
                    key:
                        ObjectKey { object_id, data: ObjectKeyData::Extent(ExtentKey { range, .. }) },
                    value: ObjectValue::Extent(ExtentValue { device_offset: Some(device_offset) }),
                }) if *object_id == self.object_id && range.start <= offset => (
                    device_offset + (offset - range.start),
                    min(buf.len() - pos, (range.end - offset) as usize),
                ),
                _ => bail!("offset {} not allocated", offset),
            };
            self.write_at(offset, buf.subslice(pos..pos + to_do), device_offset).await?;
            pos += to_do;
            if pos == buf.len() {
                break;
            }
            offset += to_do as u64;
            iter.advance_with_hint(
                &ObjectKey::extent(self.object_id, self.attribute_id, offset..end).search_key(),
            )
            .await?;
        }
        Ok(())
    }
async fn overwrite ( & self , mut offset : u64 , buf : BufferRef < ' _ > ) -> Result < ( ) , Error > { let tree = & self . store . tree ; let layer_set = tree . layer_set ( ) ; let mut merger = layer_set . merger ( ) ; let end = offset + buf . len ( ) as u64 ; let mut iter = merger . seek ( Bound :: Included ( & ObjectKey :: extent ( self . object_id , self . attribute_id , offset .. end ) . search_key ( ) , ) ) . await ? ; let mut pos = 0 ; loop { let ( device_offset , to_do ) = match iter . get ( ) { Some ( ItemRef { key : ObjectKey { object_id , data : ObjectKeyData :: Extent ( ExtentKey { range , .. } ) } , value : ObjectValue :: Extent ( ExtentValue { device_offset : Some ( device_offset ) } ) , } ) if * object_id == self . object_id && range . start <= offset => ( device_offset + ( offset - range . start ) , min ( buf . len ( ) - pos , ( range . end - offset ) as usize ) , ) , _ => bail ! ( " " offset ) , } ; self . write_at ( offset , buf . subslice ( pos .. pos + to_do ) , device_offset ) . await ? ; pos += to_do ; if pos == buf . len ( ) { break ; } offset += to_do as u64 ; iter . advance_with_hint ( & ObjectKey :: extent ( self . object_id , self . attribute_id , offset .. end ) . search_key ( ) , ) . await ? ; } Ok ( ( ) ) }
All the extents for the range must have been preallocated using preallocate_range or from
existing writes.
All the extents for the range must have been preallocated using preallocate_range or from existing writes .
&self
offset
u64
buf
BufferRef<'_>
&self
offset
u64
buf
BufferRef<'_>