Struct rofl::Engine
[−]
[src]
pub struct Engine<Tl = TemplateLoader, Fl = FontLoader> where
Tl: Loader<Item = Template>,
Fl: Loader<Item = Font>, { /* fields omitted */ }
Image captioning engine.
The engine is thread-safe (Sync
) since normally you'd want the captioning
to be performed in a background thread.
Note: Engine
implements Clone
by merely cloning a shared reference to the underlying object.
Methods
impl Engine<TemplateLoader, FontLoader>
[src]
fn new<Dt, Df>(template_directory: Dt, font_directory: Df) -> Self where
Dt: AsRef<Path>,
Df: AsRef<Path>,
Dt: AsRef<Path>,
Df: AsRef<Path>,
Create an Engine which loads templates & fonts from given directory paths. When loaded, both resources will be cached in memory (LRU cache).
impl<Tl, Fl> Engine<Tl, Fl> where
Tl: Loader<Item = Template>,
Fl: Loader<Item = Font>,
[src]
Tl: Loader<Item = Template>,
Fl: Loader<Item = Font>,
fn with_loaders(template_loader: Tl, font_loader: Fl) -> Self
Create an Engine that uses given loaders for templates & font. When loaded, both resources will be cached in memory (LRU cache).
fn with_raw_loaders(template_loader: Tl, font_loader: Fl) -> Self
Create an Engine that uses given template & font loaders directly. Any caching scheme, if necessary, should be implemented by loaders themselves.
impl<Tl, Fl> Engine<Tl, Fl> where
Tl: Loader<Item = Template>,
Fl: Loader<Item = Font>,
[src]
Tl: Loader<Item = Template>,
Fl: Loader<Item = Font>,
Render a given image macro by captioning the template with the specified text(s).
Note that captioning is a CPU-intensive process and can be relatively lengthy, especially if the template is an animated GIF. It is recommended to execute it in a separate thread.
impl<Tl, Fl> Engine<Tl, Fl> where
Tl: Loader<Item = Template>,
Fl: Loader<Item = Font>,
[src]
Tl: Loader<Item = Template>,
Fl: Loader<Item = Font>,
fn preload_template(&self, name: &str) -> Result<(), Tl::Err>
Preemptively load a template into engine's cache.
fn preload_font(&self, name: &str) -> Result<(), Fl::Err>
Preemptively load a font into engine's cache.
fn template_cache(&self) -> Option<&ThreadSafeCache<String, Tl::Item>>
Return a reference to the internal template cache, if any. This can be used to examine cache statistics (hits & misses).
fn font_cache(&self) -> Option<&ThreadSafeCache<String, Fl::Item>>
Return a reference to the internal font cache, if any. This can be used to examine cache statistics (hits & misses).
Trait Implementations
impl<Tl: Clone, Fl: Clone> Clone for Engine<Tl, Fl> where
Tl: Loader<Item = Template>,
Fl: Loader<Item = Font>,
[src]
Tl: Loader<Item = Template>,
Fl: Loader<Item = Font>,
fn clone(&self) -> Engine<Tl, Fl>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<Tl: Debug, Fl: Debug> Debug for Engine<Tl, Fl> where
Tl: Loader<Item = Template>,
Fl: Loader<Item = Font>,
[src]
Tl: Loader<Item = Template>,
Fl: Loader<Item = Font>,
impl<Tl, Fl> From<Inner<Tl, Fl>> for Engine<Tl, Fl> where
Tl: Loader<Item = Template>,
Fl: Loader<Item = Font>,
[src]
Tl: Loader<Item = Template>,
Fl: Loader<Item = Font>,
fn from(inner: Inner<Tl, Fl>) -> Self
Performs the conversion.