Trait uniffi::Lower

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, Global>);

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

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

Required Associated Constants§

Required Methods§

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

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

Provided Methods§

fn lower_into_rust_buffer(obj: Self) -> RustBuffer

Convenience method

Implementations on Foreign Types§

§

impl<UT> Lower<UT> for u32

§

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

§

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

§

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

§

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

§

impl<UT> Lower<UT> for u16

§

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

§

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

§

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

§

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

§

impl<UT> Lower<UT> for f32

§

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

§

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

§

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

§

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

§

impl<UT> Lower<UT> for i16

§

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

§

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

§

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

§

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

§

impl<UT> Lower<UT> for f64

§

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

§

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

§

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

§

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

§

impl<UT> Lower<UT> for String

§

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

§

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

§

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

§

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

§

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

§

type FfiType = RustBuffer

§

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

§

fn lower(obj: Vec<T, Global>) -> RustBuffer

§

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

§

impl<UT> Lower<UT> for u8

§

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

§

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

§

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

§

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

§

impl<UT> Lower<UT> for SystemTime

§

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

§

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

§

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

§

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

§

impl<UT> Lower<UT> for i64

§

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

§

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

§

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

§

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

§

impl<UT> Lower<UT> for i8

§

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

§

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

§

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

§

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

§

impl<UT> Lower<UT> for bool

§

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

§

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

§

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

§

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

§

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

§

type FfiType = RustBuffer

§

fn write(obj: HashMap<K, V, RandomState>, buf: &mut Vec<u8, Global>)

§

fn lower(obj: HashMap<K, V, RandomState>) -> RustBuffer

§

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> Lower<UT> for i32

§

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

§

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

§

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

§

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

§

impl<UT> Lower<UT> for u64

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

Implementors§

§

impl<UT> Lower<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> Lower<UT> for Option<T>where T: Lower<UT>,

§

type FfiType = RustBuffer

§

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