fn seek(&mut self, pos: io::SeekFrom) -> io::Result<u64> {
        let (base_pos, offset) = match pos {
            SeekFrom::Start(n) => {
                self.position = n;
                return Ok(n);
            }
            SeekFrom::End(n) => (self.cache.get_file_size(), n),
            SeekFrom::Current(n) => (self.position, n),
        };
        let new_pos = if offset >= 0 {
            base_pos.checked_add(offset as u64)
        } else {
            base_pos.checked_sub((offset.wrapping_neg()) as u64)
        };
        match new_pos {
            Some(n) => {
                self.position = n;
                Ok(self.position)
            }
            None => Err(io::Error::new(
                io::ErrorKind::InvalidInput,
                anyhow!("invalid seek to a negative or overflowing position"),
            )),
        }
    }
/// implementation inspired from std::io::Cursor
implementation inspired from std::io::Cursor
implementation inspired from std :: io :: Cursor
fn seek(&mut self, pos: io::SeekFrom) -> io::Result<u64> {
        let (base_pos, offset) = match pos {
            SeekFrom::Start(n) => {
                self.position = n;
                return Ok(n);
            }
            SeekFrom::End(n) => (self.cache.get_file_size(), n),
            SeekFrom::Current(n) => (self.position, n),
        };
        let new_pos = if offset >= 0 {
            base_pos.checked_add(offset as u64)
        } else {
            base_pos.checked_sub((offset.wrapping_neg()) as u64)
        };
        match new_pos {
            Some(n) => {
                self.position = n;
                Ok(self.position)
            }
            None => Err(io::Error::new(
                io::ErrorKind::InvalidInput,
                anyhow!("invalid seek to a negative or overflowing position"),
            )),
        }
    }
fn seek ( & mut self , pos : io :: SeekFrom ) -> io :: Result < u64 > { let ( base_pos , offset ) = match pos { SeekFrom :: Start ( n ) => { self . position = n ; return Ok ( n ) ; } SeekFrom :: End ( n ) => ( self . cache . get_file_size ( ) , n ) , SeekFrom :: Current ( n ) => ( self . position , n ) , } ; let new_pos = if offset >= 0 { base_pos . checked_add ( offset as u64 ) } else { base_pos . checked_sub ( ( offset . wrapping_neg ( ) ) as u64 ) } ; match new_pos { Some ( n ) => { self . position = n ; Ok ( self . position ) } None => Err ( io :: Error :: new ( io :: ErrorKind :: InvalidInput , anyhow ! ( " " ) , ) ) , } }
implementation inspired from std::io::Cursor
implementation inspired from std :: io :: Cursor
&mut self
pos
io::SeekFrom
&mut self
pos
io::SeekFrom