Skip to main content

GetData

Trait GetData 

Source
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§

Source

fn try_data(self) -> Result<T, ()>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl GetData<()> for Value

Source§

impl GetData<Arc<Vec<bool>>> for Value

Source§

impl GetData<Arc<Vec<char>>> for Value

Source§

impl GetData<Arc<Vec<f32>>> for Value

Source§

impl GetData<Arc<Vec<f64>>> for Value

Source§

impl GetData<Arc<Vec<i8>>> for Value

Source§

impl GetData<Arc<Vec<i16>>> for Value

Source§

impl GetData<Arc<Vec<i32>>> for Value

Source§

impl GetData<Arc<Vec<i64>>> for Value

Source§

impl GetData<Arc<Vec<i128>>> for Value

Source§

impl GetData<Arc<Vec<u8>>> for Value

Source§

impl GetData<Arc<Vec<u16>>> for Value

Source§

impl GetData<Arc<Vec<u32>>> for Value

Source§

impl GetData<Arc<Vec<u64>>> for Value

Source§

impl GetData<Arc<Vec<u128>>> for Value

Source§

impl GetData<Arc<dyn Data>> for Value

Source§

impl GetData<PackedArray> for Value

Source§

impl GetData<String> for Value

Source§

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.

Source§

impl GetData<bool> for Value

Source§

impl GetData<char> for Value

Source§

impl GetData<f32> for Value

Source§

impl GetData<f64> for Value

Source§

impl GetData<i8> for Value

Source§

impl GetData<i16> for Value

Source§

impl GetData<i32> for Value

Source§

impl GetData<i64> for Value

Source§

impl GetData<i128> for Value

Source§

impl GetData<u8> for Value

Source§

impl GetData<u16> for Value

Source§

impl GetData<u32> for Value

Source§

impl GetData<u64> for Value

Source§

impl GetData<u128> for Value

Source§

impl<D> GetData<Arc<D>> for Value
where 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.

Source§

impl<T> GetData<Option<T>> for Value
where Value: GetData<T>,

Source§

impl<T> GetData<Vec<T>> for Value
where T: 'static, Value: GetData<T>,