Struct Zim

Source
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

Source

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.

Source

pub fn article_count(&self) -> usize

Get the number of articles.

Source

pub fn verify_checksum(&self) -> Result<()>

Computes the checksum, and returns an error if it does not match the one in the file.

Source

pub fn get_mimetype(&self, id: u16) -> Option<MimeType>

Indexes into the ZIM mime_table.

Source

pub fn iterate_by_urls(&self) -> DirectoryIterator<'_>

Iterates over articles, sorted by URL.

For performance reasons, you might want to extract by cluster instead.

Source

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

Source

pub fn get_cluster(&self, idx: u32) -> Result<Cluster<'_>>

Returns the given Cluster

idx must be between 0 and cluster_count

Auto Trait Implementations§

§

impl Freeze for Zim

§

impl RefUnwindSafe for Zim

§

impl Send for Zim

§

impl Sync for Zim

§

impl Unpin for Zim

§

impl UnwindSafe for Zim

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.