pub struct ResourceIdentifier { /* private fields */ }Expand description
Case-insensitive (resname, restype) identifier.
Equality and hashing are normalized to lowercase filename form so that identifiers compare the way KotOR resource lookups typically behave.
Implementations§
Source§impl ResourceIdentifier
impl ResourceIdentifier
Sourcepub fn new(resname: impl Into<String>, restype: ResourceType) -> Self
pub fn new(resname: impl Into<String>, restype: ResourceType) -> Self
Creates a new identifier from parts.
Sourcepub fn from_path(path: impl AsRef<Path>) -> Self
pub fn from_path(path: impl AsRef<Path>) -> Self
Parses an identifier from a path-like input.
Parsing uses the final path component and maps its extension to
ResourceType. Unknown extensions map to ResourceType::Invalid.
Sourcepub fn restype(&self) -> ResourceType
pub fn restype(&self) -> ResourceType
Returns the parsed resource type.
Sourcepub fn unpack(&self) -> (&str, ResourceType)
pub fn unpack(&self) -> (&str, ResourceType)
Returns (resname, restype) as borrowed values.
Sourcepub fn resref(&self) -> Result<ResRef, ResRefError>
pub fn resref(&self) -> Result<ResRef, ResRefError>
Converts the resource name into a validated ResRef.
§Errors
Whatever ResRef::new reports: a name longer than sixteen bytes once
encoded, or one carrying a character Windows-1252 cannot hold. An
identifier can be built from a name that is not a legal resref, so this
is where that shows up.
Trait Implementations§
Source§impl Clone for ResourceIdentifier
impl Clone for ResourceIdentifier
Source§fn clone(&self) -> ResourceIdentifier
fn clone(&self) -> ResourceIdentifier
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more