pub enum MapKey {
}Expand description
A map key, owned and free of metadata: every kind Kind::is_valid_map_key admits.
Floats are held as their bit patterns. The key is Eq and Hash, and two keys are equal
exactly when the file writes the same bytes for them. The variants carry the client’s names
for the tags, as Leaf does.
Variants§
None
Bool(bool)
I8(i8)
U8(u8)
I16(i16)
U16(u16)
I32(i32)
U32(u32)
I64(i64)
U64(u64)
F32(FloatBits)
Vector2([FloatBits; 2])
Vector3([FloatBits; 3])
Vector4([FloatBits; 4])
Matrix44([FloatBits; 16])
Kind::Matrix44, row by row as the wire holds it.
Color(Color<u8>)
String(String)
Hash(HashValue)
Kind::Hash. The value includes its stored width.
File(WadHash)
Implementations§
Source§impl MapKey
impl MapKey
Sourcepub fn from_literal(literal: &KeyLiteral<'_>, kind: Kind) -> Option<Self>
pub fn from_literal(literal: &KeyLiteral<'_>, kind: Kind) -> Option<Self>
The key a {key} literal selects in a map keyed by kind, or None when the literal
does not convert.
The conversion is the one BinObject::resolve applies to a {key} subscript: a
number fills an integer or float key, a string is the text of a string key and is hashed
for a Hash or WadChunkLink key, and a number is the raw value of a hashed key.
§Examples
use ltk_hash::{BinHash, Hash as _};
use ltk_meta::{
path::{KeyLiteral, MapKey},
property::Kind,
};
let weapon = KeyLiteral::from("weapon");
assert_eq!(
MapKey::from_literal(&weapon, Kind::Hash),
Some(MapKey::Hash(BinHash::hash_str("weapon").into()))
);
assert_eq!(MapKey::from_literal(&weapon, Kind::U32), None);Source§impl MapKey
impl MapKey
Sourcepub fn from_leaf(leaf: Leaf<'_>) -> Option<Self>
pub fn from_leaf(leaf: Leaf<'_>) -> Option<Self>
A leaf as a key, or None for a Leaf::Link or a Leaf::Flag. No map is keyed by
either.
Sourcepub fn to_value(&self) -> PropertyValueEnum
pub fn to_value(&self) -> PropertyValueEnum
This key as a value of its kind.
Trait Implementations§
Source§impl Display for MapKey
The key as the text inside a {key} segment of the hash form: an integer in decimal, a float in
its shortest round-trip form, a string as a JSON string, a hash as lowercase zero-padded hex, a
vector, colour or matrix as its components in parentheses, and None as nothing.
impl Display for MapKey
The key as the text inside a {key} segment of the hash form: an integer in decimal, a float in
its shortest round-trip form, a string as a JSON string, a hash as lowercase zero-padded hex, a
vector, colour or matrix as its components in parentheses, and None as nothing.
§Examples
use ltk_hash::BinHash;
use ltk_meta::path::MapKey;
assert_eq!(MapKey::String("weapon".into()).to_string(), r#""weapon""#);
assert_eq!(MapKey::Hash(BinHash(0x1e6b_a0c4).into()).to_string(), "1e6ba0c4");impl Eq for MapKey
impl StructuralPartialEq for MapKey
Source§impl TryFrom<&PropertyValueEnum> for MapKey
Every kind Kind::is_valid_map_key admits converts. Metadata is dropped.
impl TryFrom<&PropertyValueEnum> for MapKey
Every kind Kind::is_valid_map_key admits converts. Metadata is dropped.
§Errors
Error::InvalidKeyType for a kind no map is keyed by.
Auto Trait Implementations§
impl Freeze for MapKey
impl RefUnwindSafe for MapKey
impl Send for MapKey
impl Sync for MapKey
impl Unpin for MapKey
impl UnsafeUnpin for MapKey
impl UnwindSafe for MapKey
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.