pub struct GeneratedResourceProvider<R> { /* private fields */ }Expand description
Adapter that routes generated engine resource requests through the engine ResourceProvider.
Implementations§
Source§impl<R> GeneratedResourceProvider<R>
impl<R> GeneratedResourceProvider<R>
Sourcepub fn new(inner: R) -> Self
pub fn new(inner: R) -> Self
Wraps inner in the resource provider adapter.
Examples found in repository?
examples/pack_native_format.rs (line 99)
72fn main() -> ExitCode {
73 let Some(output) = output_path() else {
74 eprintln!("usage: pack_native_format <output path>");
75 return ExitCode::FAILURE;
76 };
77 let Some(texmf_root) = find_texmf_root() else {
78 eprintln!("cannot find a texmf-dist ls-R index");
79 return ExitCode::FAILURE;
80 };
81 let Some(texmf) = TexmfResources::from_root(texmf_root) else {
82 eprintln!("cannot load the texmf-dist ls-R index");
83 return ExitCode::FAILURE;
84 };
85 let texmf = Arc::new(texmf);
86
87 let latex = match texmf.read("latex.ltx", ResourceKind::TexInput) {
88 Ok(resource) => resource.bytes,
89 Err(error) => {
90 eprintln!("cannot read latex.ltx: {error:?}");
91 return ExitCode::FAILURE;
92 }
93 };
94
95 let cache = GeneratedFormatCache::initialized(pe::EngineProfile::xetex());
96 let mut engine = cache
97 .instantiate(
98 pe::EngineProfile::xetex(),
99 GeneratedResourceProvider::new(&*texmf),
100 )
101 .with_font_platform(GeneratedFontSystemAdapter::new(NativeFontSystem::new(
102 texmf.clone(),
103 )));
104
105 if !engine.begin_primary_input("latex.ltx", latex) {
106 eprintln!("failed to begin latex.ltx");
107 return ExitCode::FAILURE;
108 }
109 engine.run_format_initialization();
110 if !engine.begin_primary_input("preamble.tex", PREAMBLE.to_vec()) {
111 eprintln!("failed to begin preamble");
112 return ExitCode::FAILURE;
113 }
114 engine.run_format_initialization();
115
116 engine.finalize_trie();
117 let format_bytes = GeneratedFormatCache::from_engine(&engine).to_bytes();
118 let font_table = engine.native_font_table();
119 let packaged = mathtex_engine::generated::pack_packaged_format(&format_bytes, &font_table);
120 if let Err(error) = std::fs::write(&output, packaged) {
121 eprintln!("cannot write {}: {error}", output.display());
122 return ExitCode::FAILURE;
123 }
124 ExitCode::SUCCESS
125}Sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Unwraps and returns the inner resource provider.
Trait Implementations§
Source§impl<R: Clone> Clone for GeneratedResourceProvider<R>
impl<R: Clone> Clone for GeneratedResourceProvider<R>
Source§impl<R: Debug> Debug for GeneratedResourceProvider<R>
impl<R: Debug> Debug for GeneratedResourceProvider<R>
Source§impl<R> ResourceProvider for GeneratedResourceProvider<R>where
R: ResourceProvider,
impl<R> ResourceProvider for GeneratedResourceProvider<R>where
R: ResourceProvider,
Auto Trait Implementations§
impl<R> Freeze for GeneratedResourceProvider<R>where
R: Freeze,
impl<R> RefUnwindSafe for GeneratedResourceProvider<R>where
R: RefUnwindSafe,
impl<R> Send for GeneratedResourceProvider<R>where
R: Send,
impl<R> Sync for GeneratedResourceProvider<R>where
R: Sync,
impl<R> Unpin for GeneratedResourceProvider<R>where
R: Unpin,
impl<R> UnsafeUnpin for GeneratedResourceProvider<R>where
R: UnsafeUnpin,
impl<R> UnwindSafe for GeneratedResourceProvider<R>where
R: UnwindSafe,
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
Mutably borrows from an owned value. Read more