pub struct Zim {
pub header: ZimHeader,
pub master_view: Mmap,
pub file_path: PathBuf,
pub mime_table: Vec<String>,
pub url_list: Vec<u64>,
pub article_list: Vec<u32>,
pub cluster_list: Vec<u64>,
pub checksum: GenericArray<u8, <Md5 as OutputSizeUser>::OutputSize>,
}
Expand description
Represents a ZIM file
Fields§
§header: ZimHeader
§master_view: Mmap
§file_path: PathBuf
The path to the file.
mime_table: Vec<String>
List of mimetypes used in this ZIM archive
url_list: Vec<u64>
§article_list: Vec<u32>
§cluster_list: Vec<u64>
§checksum: GenericArray<u8, <Md5 as OutputSizeUser>::OutputSize>
MD5 checksum.
Implementations§
source§impl Zim
impl Zim
sourcepub fn new<P: AsRef<Path>>(p: P) -> Result<Zim>
pub fn new<P: AsRef<Path>>(p: P) -> Result<Zim>
Loads a Zim file
Loads a Zim file and parses the header, and the url, title, and cluster offset tables. The rest of the data isn’t parsed until it’s needed, so this should be fairly quick.
sourcepub fn article_count(&self) -> usize
pub fn article_count(&self) -> usize
Get the number of articles.
sourcepub fn verify_checksum(&self) -> Result<()>
pub fn verify_checksum(&self) -> Result<()>
Computes the checksum, and returns an error if it does not match the one in the file.
sourcepub fn get_mimetype(&self, id: u16) -> Option<MimeType>
pub fn get_mimetype(&self, id: u16) -> Option<MimeType>
Indexes into the ZIM mime_table.
sourcepub fn iterate_by_urls(&self) -> DirectoryIterator<'_>
pub fn iterate_by_urls(&self) -> DirectoryIterator<'_>
Iterates over articles, sorted by URL.
For performance reasons, you might want to extract by cluster instead.
sourcepub fn get_by_url_index(&self, idx: u32) -> Result<DirectoryEntry>
pub fn get_by_url_index(&self, idx: u32) -> Result<DirectoryEntry>
Returns the DirectoryEntry
for the article found at the given URL index.
idx must be between 0 and article_count
sourcepub fn get_cluster(&self, idx: u32) -> Result<Cluster<'_>>
pub fn get_cluster(&self, idx: u32) -> Result<Cluster<'_>>
Returns the given Cluster
idx must be between 0 and cluster_count