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
Reexport items from other uniffi creates 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 Constants§
const TYPE_ID_META: MetadataBuffer
Required Associated Types§
Required Methods§
fn try_lift(v: Self::FfiType) -> Result<Self, Error>
fn try_read(buf: &mut &[u8]) -> Result<Self, Error>
Provided Methods§
Sourcefn try_lift_from_rust_buffer(v: RustBuffer) -> Result<Self, Error>
fn try_lift_from_rust_buffer(v: RustBuffer) -> Result<Self, Error>
Convenience method
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.
Implementations on Foreign Types§
Source§impl<UT> Lift<UT> for SystemTime
impl<UT> Lift<UT> for SystemTime
const TYPE_ID_META: MetadataBuffer
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>
Source§impl<UT, T> Lift<UT> for Vec<T>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).
impl<UT, T> Lift<UT> for Vec<T>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).