summaryrefslogtreecommitdiff
path: root/src/cache.rs
blob: aa9c10a01b8175370cb9a48e0f83066f26df8c6a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//! Caching of compilation artifacts.

use crate::font::FontCache;
use crate::image::ImageCache;
use crate::layout::LayoutCache;
use crate::loading::Loader;

/// Caches compilation artifacts.
pub struct Cache {
    /// Caches parsed font faces.
    pub font: FontCache,
    /// Caches decoded images.
    pub image: ImageCache,
    /// Caches layouting artifacts.
    pub layout: LayoutCache,
}

impl Cache {
    /// Create a new, empty cache.
    pub fn new(loader: &dyn Loader) -> Self {
        Self {
            font: FontCache::new(loader),
            image: ImageCache::new(),
            layout: LayoutCache::new(),
        }
    }
}