fn seek_to_option(&mut self, option: Options) -> Result<Option<u8>, Error<W::Error>> {
        let option: u8 = option.into();

        // check cache
        let mut start_of_unknown_options: u16 = 240;
        for location in self.option_location_cache.iter() {
            if location.option != 0 {
                if location.option == option {
                    self.reader.seek(SeekFrom::Start(location.ptr))?;
                    return Ok(Some(location.len));
                }

                start_of_unknown_options = location.ptr + u16::from(location.len);
            } else {
                break;
            }
        }

        // seek to start of options
        self.reader
            .seek(SeekFrom::Start(start_of_unknown_options))?;

        loop {
            let (byte, len): (u8, u8) = {
                let mut buf: [u8; 2] = [0; 2];

                match self.reader.read(&mut buf) {
                    Err(e) => return Err(w5500_hl::Error::Other(e)),
                    Ok(2) => (),
                    Ok(_) => return Ok(None),
                }
                (buf[0], buf[1])
            };
            if byte == 0xFF {
                return Ok(None);
            } else if byte == 0x00 {
                if len == 0x00 {
                    continue;
                } else {
                    self.reader.seek(SeekFrom::Current(-1))?;
                }
            } else if byte == option {
                self.option_location_cache_insert(byte, len);
                return Ok(Some(len));
            } else {
                self.option_location_cache_insert(byte, len);
                self.reader.seek(SeekFrom::Current(len.into()))?;
            }
        }
    }
/// Seeks to an option and returns the length if it exists.
Seeks to an option and returns the length if it exists.
Seeks to an option and returns the length if it exists .
fn seek_to_option(&mut self, option: Options) -> Result<Option<u8>, Error<W::Error>> {
        let option: u8 = option.into();
        // check cache
        let mut start_of_unknown_options: u16 = 240;
        for location in self.option_location_cache.iter() {
            if location.option != 0 {
                if location.option == option {
                    self.reader.seek(SeekFrom::Start(location.ptr))?;
                    return Ok(Some(location.len));
                }
                start_of_unknown_options = location.ptr + u16::from(location.len);
            } else {
                break;
            }
        }
        // seek to start of options
        self.reader
            .seek(SeekFrom::Start(start_of_unknown_options))?;
        loop {
            let (byte, len): (u8, u8) = {
                let mut buf: [u8; 2] = [0; 2];
                match self.reader.read(&mut buf) {
                    Err(e) => return Err(w5500_hl::Error::Other(e)),
                    Ok(2) => (),
                    Ok(_) => return Ok(None),
                }
                (buf[0], buf[1])
            };
            if byte == 0xFF {
                return Ok(None);
            } else if byte == 0x00 {
                if len == 0x00 {
                    continue;
                } else {
                    self.reader.seek(SeekFrom::Current(-1))?;
                }
            } else if byte == option {
                self.option_location_cache_insert(byte, len);
                return Ok(Some(len));
            } else {
                self.option_location_cache_insert(byte, len);
                self.reader.seek(SeekFrom::Current(len.into()))?;
            }
        }
    }
fn seek_to_option ( & mut self , option : Options ) -> Result < Option < u8 > , Error < W :: Error > > { let option : u8 = option . into ( ) ; // check cache let mut start_of_unknown_options : u16 = 240 ; for location in self . option_location_cache . iter ( ) { if location . option != 0 { if location . option == option { self . reader . seek ( SeekFrom :: Start ( location . ptr ) ) ? ; return Ok ( Some ( location . len ) ) ; } start_of_unknown_options = location . ptr + u16 :: from ( location . len ) ; } else { break ; } } // seek to start of options self . reader . seek ( SeekFrom :: Start ( start_of_unknown_options ) ) ? ; loop { let ( byte , len ) : ( u8 , u8 ) = { let mut buf : [ u8 ; 2 ] = [ 0 ; 2 ] ; match self . reader . read ( & mut buf ) { Err ( e ) => return Err ( w5500_hl :: Error :: Other ( e ) ) , Ok ( 2 ) => ( ) , Ok ( _ ) => return Ok ( None ) , } ( buf [ 0 ] , buf [ 1 ] ) } ; if byte == 0xFF { return Ok ( None ) ; } else if byte == 0x00 { if len == 0x00 { continue ; } else { self . reader . seek ( SeekFrom :: Current ( - 1 ) ) ? ; } } else if byte == option { self . option_location_cache_insert ( byte , len ) ; return Ok ( Some ( len ) ) ; } else { self . option_location_cache_insert ( byte , len ) ; self . reader . seek ( SeekFrom :: Current ( len . into ( ) ) ) ? ; } } }
Seeks to an option and returns the length if it exists.
Seeks to an option and returns the length if it exists .
&mut self
option
Options
&mut self
option
Options