pub async fn records_slice(
        &self,
        start_offset: Offset,
        max_offset_opt: Option<Offset>,
    ) -> Result<Option<AsyncFileSlice>, StorageError> {
        match self.find_offset_position(start_offset).await? {
            Some(start_pos) => {
                trace!(
                    "found batch: {:#?} at: {}",
                    start_pos.get_batch(),
                    start_pos.get_pos()
                );
                match max_offset_opt {
                    Some(max_offset) => {
                        // check if max offset same as segment end
                        if max_offset == self.get_end_offset() {
                            trace!("max offset is same as end offset, reading to end");
                            Ok(Some(self.msg_log.as_file_slice(start_pos.get_pos())?))
                        } else {
                            trace!("end offset is supplied: {}", max_offset);
                            match self.find_offset_position(max_offset).await? {
                                Some(end_pos) => Ok(Some(self.msg_log.as_file_slice_from_to(
                                    start_pos.get_pos(),
                                    end_pos.get_pos() - start_pos.get_pos(),
                                )?)),
                                None => Err(StorageError::OffsetError(OffsetError::NotExistent)),
                            }
                        }
                    }
                    None => Ok(Some(self.msg_log.as_file_slice(start_pos.get_pos())?)),
                }
            }
            None => Ok(None),
        }
    }
/// get file slice from offset to end of segment
get file slice from offset to end of segment
get file slice from offset to end of segment
pub async fn records_slice(
        &self,
        start_offset: Offset,
        max_offset_opt: Option<Offset>,
    ) -> Result<Option<AsyncFileSlice>, StorageError> {
        match self.find_offset_position(start_offset).await? {
            Some(start_pos) => {
                trace!(
                    "found batch: {:#?} at: {}",
                    start_pos.get_batch(),
                    start_pos.get_pos()
                );
                match max_offset_opt {
                    Some(max_offset) => {
                        // check if max offset same as segment end
                        if max_offset == self.get_end_offset() {
                            trace!("max offset is same as end offset, reading to end");
                            Ok(Some(self.msg_log.as_file_slice(start_pos.get_pos())?))
                        } else {
                            trace!("end offset is supplied: {}", max_offset);
                            match self.find_offset_position(max_offset).await? {
                                Some(end_pos) => Ok(Some(self.msg_log.as_file_slice_from_to(
                                    start_pos.get_pos(),
                                    end_pos.get_pos() - start_pos.get_pos(),
                                )?)),
                                None => Err(StorageError::OffsetError(OffsetError::NotExistent)),
                            }
                        }
                    }
                    None => Ok(Some(self.msg_log.as_file_slice(start_pos.get_pos())?)),
                }
            }
            None => Ok(None),
        }
    }
pub async fn records_slice ( & self , start_offset : Offset , max_offset_opt : Option < Offset > , ) -> Result < Option < AsyncFileSlice > , StorageError > { match self . find_offset_position ( start_offset ) . await ? { Some ( start_pos ) => { trace ! ( " " start_pos get_batch ( ) start_pos get_pos ( ) ) ; match max_offset_opt { Some ( max_offset ) => { // check if max offset same as segment end if max_offset == self . get_end_offset ( ) { trace ! ( " " ) ; Ok ( Some ( self . msg_log . as_file_slice ( start_pos . get_pos ( ) ) ? ) ) } else { trace ! ( " " max_offset ) ; match self . find_offset_position ( max_offset ) . await ? { Some ( end_pos ) => Ok ( Some ( self . msg_log . as_file_slice_from_to ( start_pos . get_pos ( ) , end_pos . get_pos ( ) - start_pos . get_pos ( ) , ) ? ) ) , None => Err ( StorageError :: OffsetError ( OffsetError :: NotExistent ) ) , } } } None => Ok ( Some ( self . msg_log . as_file_slice ( start_pos . get_pos ( ) ) ? ) ) , } } None => Ok ( None ) , } }
get file slice from offset to end of segment
get file slice from offset to end of segment
&self
start_offset
Offset
max_offset_opt
Option<Offset>
&self
start_offset
Offset
max_offset_opt
Option<Offset>