pub fn assert_coherence(&self) -> CacheResult<()> {
        for (archive_id, metadata) in self.metadatas().iter() {
            let query = format!("SELECT CRC, VERSION FROM cache WHERE KEY={}", archive_id);

            let mut statement = self.connection.prepare(&query)?;
            statement.next()?;
            let crc = statement.read::<i64>(0)?;
            let version = statement.read::<i64>(1)?;

            // wut
            let crc_offset = match self.index_id() {
                IndexType::SPRITES => 2_i64,
                IndexType::MODELSRT7 => 2_i64,
                _ => 1_i64,
            };
            if crc == 0 && version == 0 {
                return Err(CacheError::ArchiveNotFoundError(metadata.index_id(), metadata.archive_id()));
            } else if metadata.crc() as i64 + crc_offset != crc {
                return Err(CacheError::CrcError(
                    metadata.index_id(),
                    metadata.archive_id(),
                    metadata.crc() as i64 + crc_offset,
                    crc,
                ));
            } else if metadata.version() as i64 != version {
                return Err(CacheError::VersionError(
                    metadata.index_id(),
                    metadata.archive_id(),
                    metadata.version() as i64,
                    version,
                ));
            }
        }
        Ok(())
    }
/// Assert whether the cache held by `self` is in a coherent state.
///
/// # Errors
///
/// May raise [`CrcError`](CacheError::CrcError), [`VersionError`](CacheError::VersionError) or [`ArchiveNotFoundError`](CacheError::ArchiveNotFoundError)
/// if the cache is not in a logical state.
///
/// # Notes
/// Indices `VORBIS`, `AUDIOSTREAMS`, `TEXTURES_PNG_MIPPED` and `TEXTURES_ETC` tend to never complete.
/// For these, simply ignore [`ArchiveNotFoundError`](CacheError::ArchiveNotFoundError).
Assert whether the cache held by `self` is in a coherent state.
Assert whether the cache held by ` self ` is in a coherent state .
pub fn assert_coherence(&self) -> CacheResult<()> {
        for (archive_id, metadata) in self.metadatas().iter() {
            let query = format!("SELECT CRC, VERSION FROM cache WHERE KEY={}", archive_id);
            let mut statement = self.connection.prepare(&query)?;
            statement.next()?;
            let crc = statement.read::<i64>(0)?;
            let version = statement.read::<i64>(1)?;
            // wut
            let crc_offset = match self.index_id() {
                IndexType::SPRITES => 2_i64,
                IndexType::MODELSRT7 => 2_i64,
                _ => 1_i64,
            };
            if crc == 0 && version == 0 {
                return Err(CacheError::ArchiveNotFoundError(metadata.index_id(), metadata.archive_id()));
            } else if metadata.crc() as i64 + crc_offset != crc {
                return Err(CacheError::CrcError(
                    metadata.index_id(),
                    metadata.archive_id(),
                    metadata.crc() as i64 + crc_offset,
                    crc,
                ));
            } else if metadata.version() as i64 != version {
                return Err(CacheError::VersionError(
                    metadata.index_id(),
                    metadata.archive_id(),
                    metadata.version() as i64,
                    version,
                ));
            }
        }
        Ok(())
    }
pub fn assert_coherence ( & self ) -> CacheResult < ( ) > { for ( archive_id , metadata ) in self . metadatas ( ) . iter ( ) { let query = format ! ( " " archive_id ) ; let mut statement = self . connection . prepare ( & query ) ? ; statement . next ( ) ? ; let crc = statement . read :: < i64 > ( 0 ) ? ; let version = statement . read :: < i64 > ( 1 ) ? ; // wut let crc_offset = match self . index_id ( ) { IndexType :: SPRITES => 2_i64 , IndexType :: MODELSRT7 => 2_i64 , _ => 1_i64 , } ; if crc == 0 && version == 0 { return Err ( CacheError :: ArchiveNotFoundError ( metadata . index_id ( ) , metadata . archive_id ( ) ) ) ; } else if metadata . crc ( ) as i64 + crc_offset != crc { return Err ( CacheError :: CrcError ( metadata . index_id ( ) , metadata . archive_id ( ) , metadata . crc ( ) as i64 + crc_offset , crc , ) ) ; } else if metadata . version ( ) as i64 != version { return Err ( CacheError :: VersionError ( metadata . index_id ( ) , metadata . archive_id ( ) , metadata . version ( ) as i64 , version , ) ) ; } } Ok ( ( ) ) }
Assert whether the cache held by `self` is in a coherent state.
Assert whether the cache held by ` self ` is in a coherent state .
&self
&self
errors
May raise [`CrcError`](CacheError::CrcError), [`VersionError`](CacheError::VersionError) or [`ArchiveNotFoundError`](CacheError::ArchiveNotFoundError)
if the cache is not in a logical state.
May raise [ ` CrcError ` ] ( CacheError :: CrcError ) [ ` VersionError ` ] ( CacheError :: VersionError ) or [ ` ArchiveNotFoundError ` ] ( CacheError :: ArchiveNotFoundError ) if the cache is not in a logical state .
notes
Indices `VORBIS`, `AUDIOSTREAMS`, `TEXTURES_PNG_MIPPED` and `TEXTURES_ETC` tend to never complete.
For these, simply ignore [`ArchiveNotFoundError`](CacheError::ArchiveNotFoundError).
Indices ` VORBIS ` ` AUDIOSTREAMS ` ` TEXTURES_PNG_MIPPED ` and ` TEXTURES_ETC ` tend to never complete . For these simply ignore [ ` ArchiveNotFoundError ` ] ( CacheError :: ArchiveNotFoundError ) .