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§
type FfiType: FfiDefault
Required Associated Constants§
const TYPE_ID_META: MetadataBuffer
Required Methods§
Provided Methods§
fn lower_into_rust_buffer(obj: Self) -> RustBuffer
fn lower_into_rust_buffer(obj: Self) -> RustBuffer
Convenience method