pub struct Registry {
pub domains: HashMap<String, HashMap<String, Vec<u8>>>,
}Expand description
All data from a Content Pack, grouped by domain (from manifest.toml).
Registry is an “in-memory filesystem”. It does not know the structure of the data inside files. Each plugin decides how to parse the bytes it receives.
§Structure
domains: {
"items" → { "items_edible.ron": [...bytes...], "items_material.ron": [...bytes...] },
"recipes" → { "combinations.ron": [...bytes...] },
}Fields§
§domains: HashMap<String, HashMap<String, Vec<u8>>>Domain → { filename → raw bytes }
Implementations§
Source§impl Registry
impl Registry
Sourcepub fn file(&self, domain: &str, filename: &str) -> Result<&[u8], String>
pub fn file(&self, domain: &str, filename: &str) -> Result<&[u8], String>
Get raw bytes of a specific file within a domain.
Returns an error message string if the domain or file is not found.
Sourcepub fn has_domain(&self, name: &str) -> bool
pub fn has_domain(&self, name: &str) -> bool
Check whether a domain exists.
Sourcepub fn domain(&self, name: &str) -> Result<&HashMap<String, Vec<u8>>, String>
pub fn domain(&self, name: &str) -> Result<&HashMap<String, Vec<u8>>, String>
Get all files in a domain.
Returns an error message string if the domain does not exist.
Sourcepub fn add_file(&mut self, domain: &str, filename: &str, data: Vec<u8>)
pub fn add_file(&mut self, domain: &str, filename: &str, data: Vec<u8>)
Add a file to a domain.
Sourcepub fn domain_names(&self) -> impl Iterator<Item = &str>
pub fn domain_names(&self) -> impl Iterator<Item = &str>
Iterate over all domain names.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Registry
impl RefUnwindSafe for Registry
impl Send for Registry
impl Sync for Registry
impl Unpin for Registry
impl UnsafeUnpin for Registry
impl UnwindSafe for Registry
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