uniffi

Trait Lower

Source
pub unsafe trait Lower<UT>: Sized {
    type FfiType: FfiDefault;

    const TYPE_ID_META: MetadataBuffer;

    // Required methods
    fn lower(obj: Self) -> Self::FfiType;
    fn write(obj: Self, buf: &mut Vec<u8>);

    // Provided method
    fn lower_into_rust_buffer(obj: Self) -> RustBuffer { ... }
}
Expand description

Reexport items from other uniffi creates Lower Rust values to pass them to the foreign code

This is used to pass arguments to callback interfaces. It’s usually derived from FfiConverter, except for types that only support lowering but not lifting.

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§

Required Associated Types§

Required Methods§

Source

fn lower(obj: Self) -> Self::FfiType

Source

fn write(obj: Self, buf: &mut Vec<u8>)

Provided Methods§

Source

fn lower_into_rust_buffer(obj: Self) -> RustBuffer

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<K, V, UT> Lower<UT> for HashMap<K, V>
where K: Lower<UT> + Hash + Eq, V: Lower<UT>,

Source§

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

Source§

const TYPE_ID_META: MetadataBuffer

Source§

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

Source§

fn lower(obj: Arc<T>) -> <Arc<T> as Lower<UT>>::FfiType

Source§

fn write(obj: Arc<T>, buf: &mut Vec<u8>)

Source§

impl<UT> Lower<UT> for bool

Source§

impl<UT> Lower<UT> for f32

Source§

impl<UT> Lower<UT> for f64

Source§

impl<UT> Lower<UT> for i8

Source§

impl<UT> Lower<UT> for i16

Source§

impl<UT> Lower<UT> for i32

Source§

impl<UT> Lower<UT> for i64

Source§

impl<UT> Lower<UT> for u8

Source§

impl<UT> Lower<UT> for u16

Source§

impl<UT> Lower<UT> for u32

Source§

impl<UT> Lower<UT> for u64

Source§

impl<UT> Lower<UT> for String

Source§

impl<UT> Lower<UT> for SystemTime

Source§

impl<UT, T> Lower<UT> for Vec<T>
where T: Lower<UT>,

Implementors§