pub unsafe trait UserSafe {
// Required methods
fn align_of() -> usize;
unsafe fn from_raw_sized_unchecked(ptr: *mut u8, size: usize) -> *mut Self;
// Provided methods
unsafe fn from_raw_sized(ptr: *mut u8, size: usize) -> NonNull<Self> { ... }
unsafe fn check_ptr(ptr: *const Self) { ... }
}🔬This is a nightly-only experimental API. (
sgx_platform #56975)Available on Fortanix and SGX only.
Expand description
A type that can be represented in memory as one or more UserSafeSizeds.
Required Methods§
Sourcefn align_of() -> usize
🔬This is a nightly-only experimental API. (sgx_platform #56975)
fn align_of() -> usize
sgx_platform #56975)Equivalent to align_of::<Self>.
Sourceunsafe fn from_raw_sized_unchecked(ptr: *mut u8, size: usize) -> *mut Self
🔬This is a nightly-only experimental API. (sgx_platform #56975)
unsafe fn from_raw_sized_unchecked(ptr: *mut u8, size: usize) -> *mut Self
sgx_platform #56975)Constructs a pointer to Self given a memory range in user space.
N.B., this takes a size, not a length!
§Safety
The caller must ensure the memory range is in user memory, is the correct size and is correctly aligned and points to the right type.
Provided Methods§
Sourceunsafe fn from_raw_sized(ptr: *mut u8, size: usize) -> NonNull<Self>
🔬This is a nightly-only experimental API. (sgx_platform #56975)
unsafe fn from_raw_sized(ptr: *mut u8, size: usize) -> NonNull<Self>
sgx_platform #56975)Constructs a pointer to Self given a memory range.
N.B., this takes a size, not a length!
§Safety
The caller must ensure the memory range points to the correct type.
§Panics
This function panics if:
- the pointer is not aligned.
- the pointer is null.
- the pointed-to range does not fit in the address space.
- the pointed-to range is not in user memory.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".