pub trait FromMapKey:
FromValue
+ Eq
+ Hash
+ Ord{
// Required method
fn from_mapkey<'a>(
key: &'a MapKey,
) -> Result<Self::Output<'a>, FromMapKeyError>;
}
Expand description
Trait for converting CEL map keys into Rust types.
FromMapKey
provides conversion from CEL MapKey
instances to Rust types.
This is the inverse operation of IntoMapKey
.
§Examples
use cel_cxx::{FromMapKey, MapKey};
// Convert map keys back to Rust types
let cel_key = MapKey::String("hello".to_string().into());
let rust_string = String::from_mapkey(&cel_key).unwrap();
assert_eq!(rust_string, "hello");
let cel_key = MapKey::Int(42);
let rust_int = i64::from_mapkey(&cel_key).unwrap();
assert_eq!(rust_int, 42);
Required Methods§
Sourcefn from_mapkey<'a>(key: &'a MapKey) -> Result<Self::Output<'a>, FromMapKeyError>
fn from_mapkey<'a>(key: &'a MapKey) -> Result<Self::Output<'a>, FromMapKeyError>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.