pub trait GetData<T>: Sized {
// Required method
fn try_data(self) -> Result<T, ()>;
}Expand description
Trait allowing to get real data based on Rust type.
This trait exist to circumvent E0119 that is disabling us to use TryInto. See https://github.com/rust-lang/rust/issues/50133
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl GetData<()> for Value
impl GetData<Arc<Vec<bool>>> for Value
impl GetData<Arc<Vec<char>>> for Value
impl GetData<Arc<Vec<f32>>> for Value
impl GetData<Arc<Vec<f64>>> for Value
impl GetData<Arc<Vec<i8>>> for Value
impl GetData<Arc<Vec<i16>>> for Value
impl GetData<Arc<Vec<i32>>> for Value
impl GetData<Arc<Vec<i64>>> for Value
impl GetData<Arc<Vec<i128>>> for Value
impl GetData<Arc<Vec<u8>>> for Value
impl GetData<Arc<Vec<u16>>> for Value
impl GetData<Arc<Vec<u32>>> for Value
impl GetData<Arc<Vec<u64>>> for Value
impl GetData<Arc<Vec<u128>>> for Value
impl GetData<Arc<dyn Data>> for Value
impl GetData<PackedArray> for Value
impl GetData<String> for Value
impl GetData<Value> for Value
Identity extraction: a Value handed through unchanged. This is what an unconstrained
mel generic (#[mel_function] generic T (), or any bound not restricted to custom
Data types) actually resolves to at the Rust level — the macro type-aliases every
such generic name to Value itself — so Vec<T>/Option<T> involving a bare generic
need Self: GetData<T> to hold for T = Value in order to compose with the existing
blanket Vec/Option impls below, exactly like any other scalar type does.
impl GetData<bool> for Value
impl GetData<char> for Value
impl GetData<f32> for Value
impl GetData<f64> for Value
impl GetData<i8> for Value
impl GetData<i16> for Value
impl GetData<i32> for Value
impl GetData<i64> for Value
impl GetData<i128> for Value
impl GetData<u8> for Value
impl GetData<u16> for Value
impl GetData<u32> for Value
impl GetData<u64> for Value
impl GetData<u128> for Value
impl<D> GetData<Arc<D>> for Valuewhere
D: Data,
Casts straight to a concrete Data implementor, folding the two-step
GetData::<Arc<dyn Data>>::try_data(val).unwrap().downcast_arc::<D>().unwrap() idiom
(used throughout libs/*-mel for every custom data type) into one call — and, via
recv_one_as, into one non-panicking RecvResult. Coexists with the Arc<dyn Data>
impl above without conflict: D carries an implicit Sized bound here, which the
unsized dyn Data can never satisfy, so the two can never overlap for the same type.