Trait uniffi::Lift

pub unsafe trait Lift<UT>: Sized {
    type FfiType;

    const TYPE_ID_META: MetadataBuffer;

    // Required methods
    fn try_lift(v: Self::FfiType) -> Result<Self, Error>;
    fn try_read(buf: &mut &[u8]) -> Result<Self, Error>;

    // Provided method
    fn try_lift_from_rust_buffer(v: RustBuffer) -> Result<Self, Error> { ... }
}
Expand description

Lift values passed by the foreign code over the FFI into Rust values

This is used by the code generation to handle arguments. It’s usually derived from FfiConverter, except for types that only support lifting but not lowering.

See FfiConverter for a discussion of the methods

Safety

All traits are unsafe (implementing it requires unsafe impl) because we can’t guarantee that it’s safe to pass your type out to foreign-language code and back again. Buggy implementations of this trait might violate some assumptions made by the generated code, or might not match with the corresponding code in the generated foreign-language bindings. These traits should not be used directly, only in generated code, and the generated code should have fixture tests to test that everything works correctly together.

Required Associated Types§

type FfiType

Required Associated Constants§

Required Methods§

fn try_lift(v: Self::FfiType) -> Result<Self, Error>

fn try_read(buf: &mut &[u8]) -> Result<Self, Error>

Provided Methods§

fn try_lift_from_rust_buffer(v: RustBuffer) -> Result<Self, Error>

Convenience method

Implementations on Foreign Types§

§

impl<UT> Lift<UT> for i32

§

type FfiType = <i32 as FfiConverter<UT>>::FfiType

§

fn try_lift(v: <i32 as Lift<UT>>::FfiType) -> Result<i32, Error>

§

fn try_read(buf: &mut &[u8]) -> Result<i32, Error>

§

const TYPE_ID_META: MetadataBuffer = <Self as crate::FfiConverter::<UT>>::TYPE_ID_META

§

impl<UT> Lift<UT> for u64

§

type FfiType = <u64 as FfiConverter<UT>>::FfiType

§

fn try_lift(v: <u64 as Lift<UT>>::FfiType) -> Result<u64, Error>

§

fn try_read(buf: &mut &[u8]) -> Result<u64, Error>

§

const TYPE_ID_META: MetadataBuffer = <Self as crate::FfiConverter::<UT>>::TYPE_ID_META

§

impl<UT> Lift<UT> for u8

§

type FfiType = <u8 as FfiConverter<UT>>::FfiType

§

fn try_lift(v: <u8 as Lift<UT>>::FfiType) -> Result<u8, Error>

§

fn try_read(buf: &mut &[u8]) -> Result<u8, Error>

§

const TYPE_ID_META: MetadataBuffer = <Self as crate::FfiConverter::<UT>>::TYPE_ID_META

§

impl<UT> Lift<UT> for f64

§

type FfiType = <f64 as FfiConverter<UT>>::FfiType

§

fn try_lift(v: <f64 as Lift<UT>>::FfiType) -> Result<f64, Error>

§

fn try_read(buf: &mut &[u8]) -> Result<f64, Error>

§

const TYPE_ID_META: MetadataBuffer = <Self as crate::FfiConverter::<UT>>::TYPE_ID_META

§

impl<UT> Lift<UT> for u32

§

type FfiType = <u32 as FfiConverter<UT>>::FfiType

§

fn try_lift(v: <u32 as Lift<UT>>::FfiType) -> Result<u32, Error>

§

fn try_read(buf: &mut &[u8]) -> Result<u32, Error>

§

const TYPE_ID_META: MetadataBuffer = <Self as crate::FfiConverter::<UT>>::TYPE_ID_META

§

impl<UT> Lift<UT> for i8

§

type FfiType = <i8 as FfiConverter<UT>>::FfiType

§

fn try_lift(v: <i8 as Lift<UT>>::FfiType) -> Result<i8, Error>

§

fn try_read(buf: &mut &[u8]) -> Result<i8, Error>

§

const TYPE_ID_META: MetadataBuffer = <Self as crate::FfiConverter::<UT>>::TYPE_ID_META

§

impl<UT> Lift<UT> for i64

§

type FfiType = <i64 as FfiConverter<UT>>::FfiType

§

fn try_lift(v: <i64 as Lift<UT>>::FfiType) -> Result<i64, Error>

§

fn try_read(buf: &mut &[u8]) -> Result<i64, Error>

§

const TYPE_ID_META: MetadataBuffer = <Self as crate::FfiConverter::<UT>>::TYPE_ID_META

§

impl<UT> Lift<UT> for i16

§

type FfiType = <i16 as FfiConverter<UT>>::FfiType

§

fn try_lift(v: <i16 as Lift<UT>>::FfiType) -> Result<i16, Error>

§

fn try_read(buf: &mut &[u8]) -> Result<i16, Error>

§

const TYPE_ID_META: MetadataBuffer = <Self as crate::FfiConverter::<UT>>::TYPE_ID_META

§

impl<UT> Lift<UT> for SystemTime

§

type FfiType = <SystemTime as FfiConverter<UT>>::FfiType

§

fn try_lift(v: <SystemTime as Lift<UT>>::FfiType) -> Result<SystemTime, Error>

§

fn try_read(buf: &mut &[u8]) -> Result<SystemTime, Error>

§

const TYPE_ID_META: MetadataBuffer = <Self as crate::FfiConverter::<UT>>::TYPE_ID_META

§

impl<K, V, UT> Lift<UT> for HashMap<K, V, RandomState>where K: Lift<UT> + Hash + Eq, V: Lift<UT>,

§

type FfiType = RustBuffer

§

fn try_read(buf: &mut &[u8]) -> Result<HashMap<K, V, RandomState>, Error>

§

fn try_lift(buf: RustBuffer) -> Result<HashMap<K, V, RandomState>, Error>

§

const TYPE_ID_META: MetadataBuffer = MetadataBuffer::from_code(metadata::codes::TYPE_HASH_MAP).concat(K::TYPE_ID_META).concat(V::TYPE_ID_META)

§

impl<UT> Lift<UT> for f32

§

type FfiType = <f32 as FfiConverter<UT>>::FfiType

§

fn try_lift(v: <f32 as Lift<UT>>::FfiType) -> Result<f32, Error>

§

fn try_read(buf: &mut &[u8]) -> Result<f32, Error>

§

const TYPE_ID_META: MetadataBuffer = <Self as crate::FfiConverter::<UT>>::TYPE_ID_META

§

impl<UT> Lift<UT> for u16

§

type FfiType = <u16 as FfiConverter<UT>>::FfiType

§

fn try_lift(v: <u16 as Lift<UT>>::FfiType) -> Result<u16, Error>

§

fn try_read(buf: &mut &[u8]) -> Result<u16, Error>

§

const TYPE_ID_META: MetadataBuffer = <Self as crate::FfiConverter::<UT>>::TYPE_ID_META

§

impl<T, UT> Lift<UT> for Arc<T>where Arc<T>: FfiConverter<UT>, T: ?Sized,

§

type FfiType = <Arc<T> as FfiConverter<UT>>::FfiType

§

fn try_lift(v: <Arc<T> as Lift<UT>>::FfiType) -> Result<Arc<T>, Error>

§

fn try_read(buf: &mut &[u8]) -> Result<Arc<T>, Error>

§

const TYPE_ID_META: MetadataBuffer = <Self as crate::FfiConverter::<UT>>::TYPE_ID_META

§

impl<UT> Lift<UT> for String

§

type FfiType = <String as FfiConverter<UT>>::FfiType

§

fn try_lift(v: <String as Lift<UT>>::FfiType) -> Result<String, Error>

§

fn try_read(buf: &mut &[u8]) -> Result<String, Error>

§

const TYPE_ID_META: MetadataBuffer = <Self as crate::FfiConverter::<UT>>::TYPE_ID_META

§

impl<UT, T> Lift<UT> for Vec<T, Global>where T: Lift<UT>,

Support for associative arrays via the FFI - record<u32, u64> in UDL. HashMaps are currently always passed by serializing to a buffer. We write a i32 entries count followed by each entry (string key followed by the value) in turn. (It’s a signed type due to limits of the JVM).

§

type FfiType = RustBuffer

§

fn try_read(buf: &mut &[u8]) -> Result<Vec<T, Global>, Error>

§

fn try_lift(buf: RustBuffer) -> Result<Vec<T, Global>, Error>

§

const TYPE_ID_META: MetadataBuffer = MetadataBuffer::from_code(metadata::codes::TYPE_VEC).concat(T::TYPE_ID_META)

§

impl<UT> Lift<UT> for bool

§

type FfiType = <bool as FfiConverter<UT>>::FfiType

§

fn try_lift(v: <bool as Lift<UT>>::FfiType) -> Result<bool, Error>

§

fn try_read(buf: &mut &[u8]) -> Result<bool, Error>

§

const TYPE_ID_META: MetadataBuffer = <Self as crate::FfiConverter::<UT>>::TYPE_ID_META

Implementors§

§

impl<UT> Lift<UT> for Duration

§

type FfiType = <Duration as FfiConverter<UT>>::FfiType

§

const TYPE_ID_META: MetadataBuffer = <Self as crate::FfiConverter::<UT>>::TYPE_ID_META

§

impl<UT, T> Lift<UT> for Option<T>where T: Lift<UT>,

§

type FfiType = RustBuffer

§

const TYPE_ID_META: MetadataBuffer = MetadataBuffer::from_code(metadata::codes::TYPE_OPTION).concat(T::TYPE_ID_META)