2024-06-03 22:10:52 +02:00
|
|
|
//! FFI slice helper
|
|
|
|
|
2024-05-15 20:34:51 +02:00
|
|
|
#[repr(C)]
|
|
|
|
/// Represents a span of memory (`&mut [u8]` ) as a struct usable by C code.
|
|
|
|
///
|
2024-05-28 20:37:55 +02:00
|
|
|
/// # Safety
|
|
|
|
///
|
|
|
|
/// The caller has to make sure that:
|
|
|
|
///
|
|
|
|
/// - accesses to the memory pointed to with `start` is never accessed outside `length`
|
|
|
|
/// - the lifetime of the `CByteSlice` does not outlive the memory it points to, as described in
|
|
|
|
/// the function returning this type.
|
2024-09-05 21:15:53 +02:00
|
|
|
pub struct SPByteSlice {
|
2024-05-15 20:34:51 +02:00
|
|
|
/// The start address of the memory
|
|
|
|
pub start: *mut u8,
|
|
|
|
/// The amount of memory in bytes
|
|
|
|
pub length: usize,
|
|
|
|
}
|