pub type ResourceReader = &'static (dyn ResourceReaderMethods + Send + Sync);Expand description
A static reference to a ResourceReader
If you need to initialize the resource reader at runtime, use interior mutability.
ยงExamples
pub(crate) struct ResourceReaderImpl {
resource_dir: OnceLock<PathBuf>,
}
static RESOURCE_READER: ResourceReaderImpl = ResourceReaderImpl {
resource_dir: OnceLock::new(),
};
servo::submit_resource_reader!(&RESOURCE_READER);
/// This can be called during initialization, e.g. after parsing commandline flags.
pub(crate) fn set_resource_dir(resource_dir: PathBuf) {
RESOURCE_READER.resource_dir.set(resource_dir).expect("Already initialized.")
}
impl ResourceReaderMethods for ResourceReaderImpl {
//
}