pub enum CapeStringHashKey<'a> {
Owned(CapeStringConstNoCase),
Borrowed(*const CapeCharacter, CapeSize, PhantomData<&'a ()>),
}Expand description
Class to store a platform dependent string encoding for use in case insensitive hash maps or for use of case insensitive comparisons.
For COBIA, strings go over the pipeline as null terminated. For Windows, COBIA requires UTF-16 encoding.
The CapeStringHashKey implementation uses a CapeStringConstNoCase
to store, owned string data, or allows reference to data provided
by any class that implements CapeStringConstProvider, so that
a copy of the data is not needed for hash lookups.
A convenience class CapeOpenMap is defined, that uses the
more performant hasher in the FxHasmap class and wraps members
in accordance with the above requirements.
Note that this type cannot serve as a cape string provider, as this would require a mutable interface pointer.
Variants§
Owned(CapeStringConstNoCase)
Borrowed(*const CapeCharacter, CapeSize, PhantomData<&'a ()>)
Implementations§
Source§impl<'a> CapeStringHashKey<'a>
impl<'a> CapeStringHashKey<'a>
Sourcepub fn from_string<T: AsRef<str>>(s: T) -> Self
pub fn from_string<T: AsRef<str>>(s: T) -> Self
Construct from string that owns the data
§Arguments
s- A string slice to be converted to a CapeStringHashKey
Sourcepub fn from_cape_char_const(ptr: *const CapeCharacter, size: CapeSize) -> Self
pub fn from_cape_char_const(ptr: *const CapeCharacter, size: CapeSize) -> Self
Construct from string that owns the data
§Arguments
ptr- A const CapeCharacter pointersize- Length of the string pointed to
Sourcepub fn from_string_constant<'b, T: CapeStringConstProvider>(
c: &'b T,
) -> CapeStringHashKey<'b>
pub fn from_string_constant<'b, T: CapeStringConstProvider>( c: &'b T, ) -> CapeStringHashKey<'b>
Construct from string constant provider reference that does not own the data
§Arguments
c- A string constant reference
Trait Implementations§
Source§impl<'a> Clone for CapeStringHashKey<'a>
impl<'a> Clone for CapeStringHashKey<'a>
Source§impl<'a> Debug for CapeStringHashKey<'a>
impl<'a> Debug for CapeStringHashKey<'a>
Source§impl<'a> Display for CapeStringHashKey<'a>
impl<'a> Display for CapeStringHashKey<'a>
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Formats the CapeStringConstNoCase error using the given formatter.
§Examples
use cobia;
let s=cobia::CapeStringConstNoCase::from_string("idealGasEnthalpy");
assert_eq!(format!("{}",s),"idealgasenthalpy"); //note that CapeStringConstNoCase stores strings in lower case