Struct mupdf_sys::fz_store_hash[][src]

#[repr(C)]pub struct fz_store_hash {
    pub drop: fz_store_drop_fn,
    pub u: fz_store_hash__bindgen_ty_1,
}

The store can be seen as a dictionary that maps keys to fz_storable values. In order to allow keys of different types to be stored, we have a structure full of functions for each key ‘type’; this fz_store_type pointer is stored with each key, and tells the store how to perform certain operations (like taking/ dropping a reference, comparing two keys, outputting details for debugging etc).

The store uses a hash table internally for speed where possible. In order for this to work, we need a mechanism for turning a generic ‘key’ into ‘a hashable string’. For this purpose the type structure contains a make_hash_key function pointer that maps from a void * to a fz_store_hash structure. If make_hash_key function returns 0, then the key is determined not to be hashable, and the value is not stored in the hash table.

Some objects can be used both as values within the store, and as a component of keys within the store. We refer to these objects as “key storable” objects. In this case, we need to take additional care to ensure that we do not end up keeping an item within the store, purely because its value is referred to by another key in the store.

An example of this are fz_images in PDF files. Each fz_image is placed into the store to enable it to be easily reused. When the image is rendered, a pixmap is generated from the image, and the pixmap is placed into the store so it can be reused on subsequent renders. The image forms part of the key for the pixmap.

When we close the pdf document (and any associated pages/display lists etc), we drop the images from the store. This may leave us in the position of the images having non-zero reference counts purely because they are used as part of the keys for the pixmaps.

We therefore use special reference counting functions to keep track of these “key storable” items, and hence store the number of references to these items that are used in keys.

When the number of references to an object == the number of references to an object from keys in the store, we know that we can remove all the items which have that object as part of the key. This is done by running a pass over the store, ‘reaping’ those items.

Reap passes are slower than we would like as they touch every item in the store. We therefore provide a way to ‘batch’ such reap passes together, using fz_defer_reap_start/ fz_defer_reap_end to bracket a region in which many may be triggered.

Fields

drop: fz_store_drop_fnu: fz_store_hash__bindgen_ty_1

Trait Implementations

impl Clone for fz_store_hash[src]

impl Copy for fz_store_hash[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.