fn crc_section<T, F>(
        &mut self,
        data: &[u8],
        crc: u32,
        section: &str,
        mut f: F,
    ) -> Result<T, Error>
    where
        F: FnMut(&mut Self) -> Result<T, Error>,
    {
        match (self.crc_check, f(self)) {
            (CrcCheck::Always, res) => {
                let actual = calc_crc(data);
                if actual != crc as u32 {
                    Err(Error::from(ParseError::CrcMismatch(crc, actual)))
                } else {
                    res
                }
            }
            (CrcCheck::OnError, Err(e)) => {
                let actual = calc_crc(data);
                if actual != crc as u32 {
                    Err(e
                        .context(format!(
                            "Failed to parse {} and crc check failed. Replay is corrupt",
                            section
                        ))
                        .into())
                } else {
                    Err(e)
                }
            }
            (CrcCheck::OnError, Ok(s)) => Ok(s),
            (CrcCheck::Never, res) => res,
        }
    }
/// Parses a section and performs a crc check as configured
Parses a section and performs a crc check as configured
Parses a section and performs a crc check as configured
fn crc_section<T, F>(
        &mut self,
        data: &[u8],
        crc: u32,
        section: &str,
        mut f: F,
    ) -> Result<T, Error>
    where
        F: FnMut(&mut Self) -> Result<T, Error>,
    {
        match (self.crc_check, f(self)) {
            (CrcCheck::Always, res) => {
                let actual = calc_crc(data);
                if actual != crc as u32 {
                    Err(Error::from(ParseError::CrcMismatch(crc, actual)))
                } else {
                    res
                }
            }
            (CrcCheck::OnError, Err(e)) => {
                let actual = calc_crc(data);
                if actual != crc as u32 {
                    Err(e
                        .context(format!(
                            "Failed to parse {} and crc check failed. Replay is corrupt",
                            section
                        ))
                        .into())
                } else {
                    Err(e)
                }
            }
            (CrcCheck::OnError, Ok(s)) => Ok(s),
            (CrcCheck::Never, res) => res,
        }
    }
fn crc_section < T , F > ( & mut self , data : & [ u8 ] , crc : u32 , section : & str , mut f : F , ) -> Result < T , Error > where F : FnMut ( & mut Self ) -> Result < T , Error > , { match ( self . crc_check , f ( self ) ) { ( CrcCheck :: Always , res ) => { let actual = calc_crc ( data ) ; if actual != crc as u32 { Err ( Error :: from ( ParseError :: CrcMismatch ( crc , actual ) ) ) } else { res } } ( CrcCheck :: OnError , Err ( e ) ) => { let actual = calc_crc ( data ) ; if actual != crc as u32 { Err ( e . context ( format ! ( " " section ) ) . into ( ) ) } else { Err ( e ) } } ( CrcCheck :: OnError , Ok ( s ) ) => Ok ( s ) , ( CrcCheck :: Never , res ) => res , } }
Parses a section and performs a crc check as configured
Parses a section and performs a crc check as configured
&mut self
data
&[u8]
crc
u32
section
&str
f
F
&mut self
data
&[u8]
crc
u32
section
&str
f
F