pub struct Assets { /* private fields */ }Expand description
Every image one book refers to, probed once and indexed.
DrawItem::Image.asset indexes this: layout places an image by
number, and painters resolve the number back to bytes.
Implementations§
Source§impl Assets
impl Assets
Sourcepub fn probe(
book: &Book,
styles: &StyleTree,
loader: &dyn ImageLoader,
) -> Assets
pub fn probe( book: &Book, styles: &StyleTree, loader: &dyn ImageLoader, ) -> Assets
Probes every image the book places and every image its sheet puts behind a box, the manuscript’s own first. A url the loader cannot resolve, or bytes no probe recognises, is a diagnostic and no asset.
A sheet that names no background image offers the loader nothing beyond what the manuscript named.
Sourcepub fn add(&mut self, url: &str, bytes: Vec<u8>) -> Added
pub fn add(&mut self, url: &str, bytes: Vec<u8>) -> Added
Registers one image the host handed over, and what that did: the same bytes it already had, new bytes at a fresh or existing index, or bytes no probe recognises.
This is the door for a host that pushes: a worker has no
loader to reach back through, so images cross the wall the
way font files do. A url pushed again with the bytes it
already answers for costs nothing; pushed again with
different bytes, it replaces them in place, keeping the index
DrawItem::Image.asset already names.
Sourcepub fn lookup(&self, url: &str) -> Option<(u32, Intrinsic)>
pub fn lookup(&self, url: &str) -> Option<(u32, Intrinsic)>
The asset registered for a url, and its index.
Sourcepub fn probed(&self, url: &str) -> bool
pub fn probed(&self, url: &str) -> bool
Whether a url has been probed: an asset came of it, or a complaint about why none did. A url nobody offered is neither, and is what layout reports.
Sourcepub fn bytes(&self, index: u32) -> Option<&[u8]>
pub fn bytes(&self, index: u32) -> Option<&[u8]>
The file one asset was probed from: the bytes a painter embeds, unchanged from what the host handed over.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Assets
impl RefUnwindSafe for Assets
impl Send for Assets
impl Sync for Assets
impl Unpin for Assets
impl UnsafeUnpin for Assets
impl UnwindSafe for Assets
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.