pub fn write(&mut self, mut src: &[u8], mut offset: usize) {
        use std::collections::hash_map::Entry;

        let page_size = *PAGE_SIZE;

        while !src.is_empty() {
            let page = PageIndex::new((offset / page_size) as u64);
            let offset_into_page = offset % page_size;
            let page_len = src.len().min(page_size - offset_into_page);

            match self.dirty_pages.entry(page) {
                Entry::Occupied(mut dirty_page) => {
                    Arc::make_mut(&mut dirty_page.get_mut().0).0
                        [offset_into_page..offset_into_page + page_len]
                        .copy_from_slice(&src[0..page_len]);
                }
                Entry::Vacant(page_slot) => {
                    let new_page = page_slot
                        .insert(TrackedPage::try_from(self.page_map.get_page(page)).unwrap());

                    Arc::make_mut(&mut new_page.0).0[offset_into_page..offset_into_page + page_len]
                        .copy_from_slice(&src[0..page_len]);
                }
            }

            offset += page_len;
            src = &src[page_len..src.len()];
        }
    }
/// Overwrites the contents of this buffer at the specified offset with the
/// contents of the source buffer.
Overwrites the contents of this buffer at the specified offset with the
contents of the source buffer.
Overwrites the contents of this buffer at the specified offset with the contents of the source buffer .
pub fn write(&mut self, mut src: &[u8], mut offset: usize) {
        use std::collections::hash_map::Entry;
        let page_size = *PAGE_SIZE;
        while !src.is_empty() {
            let page = PageIndex::new((offset / page_size) as u64);
            let offset_into_page = offset % page_size;
            let page_len = src.len().min(page_size - offset_into_page);
            match self.dirty_pages.entry(page) {
                Entry::Occupied(mut dirty_page) => {
                    Arc::make_mut(&mut dirty_page.get_mut().0).0
                        [offset_into_page..offset_into_page + page_len]
                        .copy_from_slice(&src[0..page_len]);
                }
                Entry::Vacant(page_slot) => {
                    let new_page = page_slot
                        .insert(TrackedPage::try_from(self.page_map.get_page(page)).unwrap());
                    Arc::make_mut(&mut new_page.0).0[offset_into_page..offset_into_page + page_len]
                        .copy_from_slice(&src[0..page_len]);
                }
            }
            offset += page_len;
            src = &src[page_len..src.len()];
        }
    }
pub fn write ( & mut self , mut src : & [ u8 ] , mut offset : usize ) { use std :: collections :: hash_map :: Entry ; let page_size = * PAGE_SIZE ; while ! src . is_empty ( ) { let page = PageIndex :: new ( ( offset / page_size ) as u64 ) ; let offset_into_page = offset % page_size ; let page_len = src . len ( ) . min ( page_size - offset_into_page ) ; match self . dirty_pages . entry ( page ) { Entry :: Occupied ( mut dirty_page ) => { Arc :: make_mut ( & mut dirty_page . get_mut ( ) . 0 ) . 0 [ offset_into_page .. offset_into_page + page_len ] . copy_from_slice ( & src [ 0 .. page_len ] ) ; } Entry :: Vacant ( page_slot ) => { let new_page = page_slot . insert ( TrackedPage :: try_from ( self . page_map . get_page ( page ) ) . unwrap ( ) ) ; Arc :: make_mut ( & mut new_page . 0 ) . 0 [ offset_into_page .. offset_into_page + page_len ] . copy_from_slice ( & src [ 0 .. page_len ] ) ; } } offset += page_len ; src = & src [ page_len .. src . len ( ) ] ; } }
Overwrites the contents of this buffer at the specified offset with the
contents of the source buffer.
Overwrites the contents of this buffer at the specified offset with the contents of the source buffer .
&mut self
src
&[u8]
offset
usize
&mut self
src
&[u8]
offset
usize