Skip to main content

ResourceTable

Struct ResourceTable 

Source
pub struct ResourceTable { /* private fields */ }
Expand description

The resource dictionaries of one page, while its streams are regenerated.

Holds the sub-dictionary per category plus the entries a previous sweep parked, so a name allocation can avoid both. A plain record: the four functions below are the operations.

Implementations§

Source§

impl ResourceTable

Source

pub fn load(resources: &Dict, r: &impl Resolve) -> Self

Read the three categories out of a page’s /Resources.

Every other key — colour spaces, patterns, /ProcSet — is left where it is and carried through untouched.

Source

pub fn realize(&mut self, category: &str, object: ObjRef) -> Name

The name object is known by in category, allocating one if it has none yet.

An object already in the category keeps the name it has — reusing an existing /F1 rather than minting FXF1 beside it — which is what keeps a page that regenerates twice from growing a resource dictionary without bound.

Source

pub fn name_of(&self, category: &str, object: ObjRef) -> Option<Name>

The name object already has in category, without allocating one.

What an object in a stream this run is not rewriting needs: the stream refers to the resource by the name it already spells, so the name has to be found rather than minted — and if there is none, there is nothing to keep alive.

Source

pub fn name_of_dict(&self, category: &str, value: &Dict) -> Option<Name>

The name an equal direct dictionary already has in category, without allocating one.

Source

pub fn realize_dict(&mut self, category: &str, value: &Dict) -> Name

Add a direct dictionary — an /ExtGState the emitter built rather than found — under a fresh name, or return the name an equal one already has.

Source

pub fn sweep(&mut self, used: &BTreeMap<String, BTreeSet<Name>>)

Drop every entry no object used, parking it in case a later regeneration wants it back, and restore any parked entry that is wanted now.

used names, per category, exactly what the regenerated streams referred to — every name Self::realize handed out and nothing else. A name the caller allocated and then forgot to list is swept away, so the caller records at the point of allocation.

Source

pub fn to_dict(&self, base: &Dict) -> Dict

The /Resources dictionary this table describes, built onto base so that categories the table does not maintain survive untouched.

Trait Implementations§

Source§

impl Clone for ResourceTable

Source§

fn clone(&self) -> ResourceTable

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ResourceTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ResourceTable

Source§

fn default() -> ResourceTable

Returns the “default value” for a type. Read more

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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.