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
impl ResourceTable
Sourcepub fn load(resources: &Dict, r: &impl Resolve) -> Self
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.
Sourcepub fn realize(&mut self, category: &str, object: ObjRef) -> Name
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.
Sourcepub fn name_of(&self, category: &str, object: ObjRef) -> Option<Name>
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.
Sourcepub fn name_of_dict(&self, category: &str, value: &Dict) -> Option<Name>
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.
Sourcepub fn realize_dict(&mut self, category: &str, value: &Dict) -> Name
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.
Sourcepub fn sweep(&mut self, used: &BTreeMap<String, BTreeSet<Name>>)
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.
Trait Implementations§
Source§impl Clone for ResourceTable
impl Clone for ResourceTable
Source§fn clone(&self) -> ResourceTable
fn clone(&self) -> ResourceTable
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more