fn seek(&mut self, pos: SeekFrom) -> std::io::Result<u64> {
        let new_offset: Option<u64> = match pos {
            SeekFrom::Start(off) => Some(off),
            SeekFrom::End(off) => {
                if off < 0 {
                    0i64.checked_sub(off).and_then(|increment| {
                        self.virtual_disk_size().checked_sub(increment as u64)
                    })
                } else {
                    self.virtual_disk_size().checked_add(off as u64)
                }
            }
            SeekFrom::Current(off) => {
                if off < 0 {
                    0i64.checked_sub(off)
                        .and_then(|increment| self.current_offset.checked_sub(increment as u64))
                } else {
                    self.current_offset.checked_add(off as u64)
                }
            }
        };

        if let Some(o) = new_offset {
            if o <= self.virtual_disk_size() {
                self.current_offset = o;
                return Ok(o);
            }
        }

        Err(std::io::Error::new(
            std::io::ErrorKind::InvalidData,
            "Failed seek operation",
        ))
    }
/// Wrapper function to satisfy Seek trait implementation for VHDx disk.
/// Updates the offset field in the Vhdx struct.
Wrapper function to satisfy Seek trait implementation for VHDx disk.
Updates the offset field in the Vhdx struct.
Wrapper function to satisfy Seek trait implementation for VHDx disk . Updates the offset field in the Vhdx struct .
fn seek(&mut self, pos: SeekFrom) -> std::io::Result<u64> {
        let new_offset: Option<u64> = match pos {
            SeekFrom::Start(off) => Some(off),
            SeekFrom::End(off) => {
                if off < 0 {
                    0i64.checked_sub(off).and_then(|increment| {
                        self.virtual_disk_size().checked_sub(increment as u64)
                    })
                } else {
                    self.virtual_disk_size().checked_add(off as u64)
                }
            }
            SeekFrom::Current(off) => {
                if off < 0 {
                    0i64.checked_sub(off)
                        .and_then(|increment| self.current_offset.checked_sub(increment as u64))
                } else {
                    self.current_offset.checked_add(off as u64)
                }
            }
        };
        if let Some(o) = new_offset {
            if o <= self.virtual_disk_size() {
                self.current_offset = o;
                return Ok(o);
            }
        }
        Err(std::io::Error::new(
            std::io::ErrorKind::InvalidData,
            "Failed seek operation",
        ))
    }
fn seek ( & mut self , pos : SeekFrom ) -> std :: io :: Result < u64 > { let new_offset : Option < u64 > = match pos { SeekFrom :: Start ( off ) => Some ( off ) , SeekFrom :: End ( off ) => { if off < 0 { 0i64 . checked_sub ( off ) . and_then ( | increment | { self . virtual_disk_size ( ) . checked_sub ( increment as u64 ) } ) } else { self . virtual_disk_size ( ) . checked_add ( off as u64 ) } } SeekFrom :: Current ( off ) => { if off < 0 { 0i64 . checked_sub ( off ) . and_then ( | increment | self . current_offset . checked_sub ( increment as u64 ) ) } else { self . current_offset . checked_add ( off as u64 ) } } } ; if let Some ( o ) = new_offset { if o <= self . virtual_disk_size ( ) { self . current_offset = o ; return Ok ( o ) ; } } Err ( std :: io :: Error :: new ( std :: io :: ErrorKind :: InvalidData , " " , ) ) }
Wrapper function to satisfy Seek trait implementation for VHDx disk.
Wrapper function to satisfy Seek trait implementation for VHDx disk .
&mut self
pos
SeekFrom
&mut self
pos
SeekFrom