Skip to main content

FfiSlice

Trait FfiSlice 

Source
pub trait FfiSlice<T> {
    // Required method
    fn as_ffi_ptr(&self) -> *const T;

    // Provided method
    fn as_ffi_void_ptr(&self) -> *const c_void { ... }
}
Expand description

FfiSlice exists to provide as_ffi_ptr on slices. Calling as_ptr on an empty Rust slice may return the alignment of the type, rather than NULL, as the pointer. When passing pointers into C/C++ code, that is not a valid pointer. Thus this method should be used whenever passing a pointer to a slice into BoringSSL code.

Required Methods§

Source

fn as_ffi_ptr(&self) -> *const T

Cast the slice into a valid raw pointer for FFI.

Provided Methods§

Source

fn as_ffi_void_ptr(&self) -> *const c_void

Cast the slice into a valid const void * pointer for FFI.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T, const N: usize> FfiSlice<T> for [T; N]

Source§

impl<T> FfiSlice<T> for [T]

Implementors§