fz_store_hash

Struct fz_store_hash 

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

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_fn§u: fz_store_hash__bindgen_ty_1

Trait Implementations§

Source§

impl Clone for fz_store_hash

Source§

fn clone(&self) -> fz_store_hash

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for fz_store_hash

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.