Created
March 14, 2020 05:23
-
-
Save mysteriouspants/ba83b992134ff34bc09fdc397b08bb2e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub trait Source : Read + Seek + Send { } | |
impl<TSource: Source> NoMemEntryStore<TSource> { | |
/// Reads an archive from an input source. Optionally scans each entry | |
/// header, which would detect errors in the archive earlier. | |
pub fn from_source( | |
source: &mut TSource, verify: bool | |
) -> Result<NoMemEntryStore<TSource>, ArchiveParseError> { | |
let archive = Archive::load_from(source)?; | |
if verify { | |
// loop through all the entries and validate they they can be parsed | |
source.seek(SeekFrom::Start(archive.archive_start as u64))?; | |
for _i in 1 ..= archive.archive_size { | |
Entry::load_from( | |
&mut source, &opts_for_archive( | |
&archive.archive_version, &archive.archive_type | |
) | |
)?; | |
} | |
} | |
return Ok(NoMemEntryStore::<TSource> { archive, source, }); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment