pub struct Types { /* private fields */ }Expand description
The type graph: aliases, subclasses and descriptions.
Implementations§
Source§impl Types
impl Types
Sourcepub fn load_from(dirs: &[PathBuf]) -> Types
pub fn load_from(dirs: &[PathBuf]) -> Types
Reads aliases and subclasses from every directory given.
Descriptions are not read here: they are one XML file per type,
some thousands of them, and nothing needs them until something
asks for one. Types::describe_from reads the one file.
Sourcepub fn add_aliases(&mut self, text: &str)
pub fn add_aliases(&mut self, text: &str)
alias canonical, one per line. The first file to name an alias
keeps it, so a user’s own database entry beats the system’s.
Sourcepub fn add_subclasses(&mut self, text: &str)
pub fn add_subclasses(&mut self, text: &str)
child parent, one per line. A type can have several parents,
and each is kept.
Sourcepub fn canonical<'a>(&'a self, mime: &'a str) -> &'a str
pub fn canonical<'a>(&'a self, mime: &'a str) -> &'a str
The name the rest of the database uses for this type.
Aliases do not chain in practice, but a database that claimed they did would otherwise hang here, so this follows at most a few links and then stops.
Sourcepub fn is_subclass_of(&self, mime: &str, parent: &str) -> bool
pub fn is_subclass_of(&self, mime: &str, parent: &str) -> bool
Whether mime is parent, or a kind of it.
Includes the two rules the file does not carry — see the module
doc — so text/x-shellscript is a text/plain and everything is
an application/octet-stream.
Sourcepub fn ancestors(&self, mime: &str) -> Vec<String>
pub fn ancestors(&self, mime: &str) -> Vec<String>
Every type this one is a kind of, nearest first — for finding an application when nothing is registered for the exact type. A 3MF with no 3MF viewer can still be opened by an archive manager.
Sourcepub fn describe_from(
&mut self,
dirs: &[PathBuf],
mime: &str,
language: Option<&str>,
) -> Option<&str>
pub fn describe_from( &mut self, dirs: &[PathBuf], mime: &str, language: Option<&str>, ) -> Option<&str>
Reads one type’s description out of <media>/<subtype>.xml,
remembering it.
language is an xml:lang to prefer — "de" finds
<comment xml:lang="de">; the untagged comment is the fallback,
which is what a request for English gets, since the database
leaves English untagged.