pub trait FileHandler<T: Send>: Sync + Send {
// Required methods
fn subpath(&self) -> PathBuf;
fn load_file(&self, entry: &FileEntry, parser: &ParserMemory) -> Option<T>;
fn handle_file(&mut self, entry: &FileEntry, loaded: T);
// Provided methods
fn config(&mut self, _config: &Block) { ... }
fn finalize(&mut self) { ... }
}
Expand description
A trait for a submodule that can process files.
Required Methods§
Sourcefn subpath(&self) -> PathBuf
fn subpath(&self) -> PathBuf
Which files this handler is interested in. This is a directory prefix of files it wants to handle, relative to the mod or vanilla root.
Sourcefn load_file(&self, entry: &FileEntry, parser: &ParserMemory) -> Option<T>
fn load_file(&self, entry: &FileEntry, parser: &ParserMemory) -> Option<T>
This is called for each matching file, in arbitrary order.
If a T
is returned, it will be passed to handle_file
later.
Since load_file
is executed multi-threaded while handle_file
is single-threaded, try to do the heavy work in this function.
Sourcefn handle_file(&mut self, entry: &FileEntry, loaded: T)
fn handle_file(&mut self, entry: &FileEntry, loaded: T)
This is called for each matching file in turn, in lexical order. That’s the order in which the CK3 game engine loads them too.