pub fn truncate(&mut self, offset: Offset) -> Option<u32> {
        // find the next offset position in order to inform
        // the truncation of the segment
        let next_pos = match self.find_index_pos(offset + 1) {
            Some(i) => {
                trace!("Found offset mem offset {}", i);
                i
            }
            None => {
                trace!("No offset {} found in index", offset + 1);
                return None;
            }
        };

        let mem = &mut self.mmap[..];

        let (off, file_len) = entry!(mem, next_pos);

        // find_index_pos will find the right-most position, which may include
        // something <= the offset passed in, which we should reject for
        // truncation. This likely occurs when the last offset is the offset
        // requested for truncation OR the offset for truncation is > than the
        // last offset.
        if u64::from(off) + self.base_offset <= offset {
            trace!("Truncated to exact segment boundary, no need to truncate segment");
            return None;
        }

        trace!("Start of truncation at offset {}, to segment length {}", offset, file_len);

        // override file positions > offset
        for elem in &mut mem[next_pos..self.next_write_pos].iter_mut() {
            *elem = 0;
        }

        // re-adjust the next file pos
        self.next_write_pos = next_pos;

        Some(file_len)
    }
/// Truncates to an offset, inclusive. The file length of the
/// segment for truncation is returned.
Truncates to an offset, inclusive. The file length of the
segment for truncation is returned.
Truncates to an offset inclusive . The file length of the segment for truncation is returned .
pub fn truncate(&mut self, offset: Offset) -> Option<u32> {
        // find the next offset position in order to inform
        // the truncation of the segment
        let next_pos = match self.find_index_pos(offset + 1) {
            Some(i) => {
                trace!("Found offset mem offset {}", i);
                i
            }
            None => {
                trace!("No offset {} found in index", offset + 1);
                return None;
            }
        };
        let mem = &mut self.mmap[..];
        let (off, file_len) = entry!(mem, next_pos);
        // find_index_pos will find the right-most position, which may include
        // something <= the offset passed in, which we should reject for
        // truncation. This likely occurs when the last offset is the offset
        // requested for truncation OR the offset for truncation is > than the
        // last offset.
        if u64::from(off) + self.base_offset <= offset {
            trace!("Truncated to exact segment boundary, no need to truncate segment");
            return None;
        }
        trace!("Start of truncation at offset {}, to segment length {}", offset, file_len);
        // override file positions > offset
        for elem in &mut mem[next_pos..self.next_write_pos].iter_mut() {
            *elem = 0;
        }
        // re-adjust the next file pos
        self.next_write_pos = next_pos;
        Some(file_len)
    }
pub fn truncate ( & mut self , offset : Offset ) -> Option < u32 > { // find the next offset position in order to inform // the truncation of the segment let next_pos = match self . find_index_pos ( offset + 1 ) { Some ( i ) => { trace ! ( " " i ) ; i } None => { trace ! ( " " offset 1 ) ; return None ; } } ; let mem = & mut self . mmap [ .. ] ; let ( off , file_len ) = entry ! ( mem next_pos ) ; // find_index_pos will find the right-most position, which may include // something <= the offset passed in, which we should reject for // truncation. This likely occurs when the last offset is the offset // requested for truncation OR the offset for truncation is > than the // last offset. if u64 :: from ( off ) + self . base_offset <= offset { trace ! ( " " ) ; return None ; } trace ! ( " " offset file_len ) ; // override file positions > offset for elem in & mut mem [ next_pos .. self . next_write_pos ] . iter_mut ( ) { * elem = 0 ; } // re-adjust the next file pos self . next_write_pos = next_pos ; Some ( file_len ) }
Truncates to an offset, inclusive.
Truncates to an offset inclusive .
&mut self
offset
Offset
&mut self
offset
Offset