#[repr(C)]pub struct NativeAbiBorrowedBytes {
pub ptr: *const u8,
pub len: usize,
}Expand description
A borrowed byte slice passed by raw pointer across the ABI boundary.
Fields§
§ptr: *const u8Pointer to the first byte, or null when empty.
len: usizeNumber of bytes addressed by ptr.
Implementations§
Source§impl NativeAbiBorrowedBytes
impl NativeAbiBorrowedBytes
Sourcepub fn borrow(bytes: &[u8]) -> Self
pub fn borrow(bytes: &[u8]) -> Self
Borrows an existing slice for the duration of a single ABI call.
§Examples
use sim_kernel::NativeAbiBorrowedBytes;
let payload = [1u8, 2, 3];
let borrowed = NativeAbiBorrowedBytes::borrow(&payload);
assert_eq!(borrowed.len, 3);
assert!(!borrowed.ptr.is_null());
let empty = NativeAbiBorrowedBytes::empty();
assert_eq!(empty.len, 0);
assert!(empty.ptr.is_null());Trait Implementations§
Source§impl Clone for NativeAbiBorrowedBytes
impl Clone for NativeAbiBorrowedBytes
Source§fn clone(&self) -> NativeAbiBorrowedBytes
fn clone(&self) -> NativeAbiBorrowedBytes
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for NativeAbiBorrowedBytes
Auto Trait Implementations§
impl !Send for NativeAbiBorrowedBytes
impl !Sync for NativeAbiBorrowedBytes
impl Freeze for NativeAbiBorrowedBytes
impl RefUnwindSafe for NativeAbiBorrowedBytes
impl Unpin for NativeAbiBorrowedBytes
impl UnsafeUnpin for NativeAbiBorrowedBytes
impl UnwindSafe for NativeAbiBorrowedBytes
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more