pub struct User<T: UserSafe + ?Sized>(/* private fields */);sgx_platform #56975)Expand description
An owned type in userspace memory. User<T> is equivalent to Box<T> in
enclave memory. Access to the memory is only allowed by copying to avoid
TOCTTOU issues. The user memory will be freed when the value is dropped.
After copying, code should make sure to completely check the value before
use.
Implementations§
Source§impl<T> User<T>
impl<T> User<T>
Source§impl<T> User<T>where
T: UserSafe,
impl<T> User<T>where
T: UserSafe,
Sourcepub fn uninitialized() -> Self
🔬This is a nightly-only experimental API. (sgx_platform #56975)
pub fn uninitialized() -> Self
sgx_platform #56975)Allocates space for T in user memory.
Source§impl<T> User<[T]>
impl<T> User<[T]>
Sourcepub fn uninitialized(n: usize) -> Self
🔬This is a nightly-only experimental API. (sgx_platform #56975)
pub fn uninitialized(n: usize) -> Self
sgx_platform #56975)Allocates space for a [T] of n elements in user memory.
Sourcepub unsafe fn from_raw_parts(ptr: *mut T, len: usize) -> Self
🔬This is a nightly-only experimental API. (sgx_platform #56975)
pub unsafe fn from_raw_parts(ptr: *mut T, len: usize) -> Self
sgx_platform #56975)Creates an owned User<[T]> from a raw thin pointer and a slice length.
§Safety
The caller must ensure ptr points to len elements of T, is
freeable with the free usercall and the alignment of T, and is
uniquely owned.
§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
Methods from Deref<Target = UserRef<T>>§
Sourcepub fn copy_from_enclave(&mut self, val: &T)
🔬This is a nightly-only experimental API. (sgx_platform #56975)
pub fn copy_from_enclave(&mut self, val: &T)
sgx_platform #56975)Copies val into user memory.
§Panics
This function panics if the destination doesn’t have the same size as the source. This can happen for dynamically-sized types such as slices.
Sourcepub fn copy_to_enclave<U: ?Sized + UserSafeCopyDestination<T>>(
&self,
dest: &mut U,
)
🔬This is a nightly-only experimental API. (sgx_platform #56975)
pub fn copy_to_enclave<U: ?Sized + UserSafeCopyDestination<T>>( &self, dest: &mut U, )
sgx_platform #56975)Copies the value from user memory and place it into dest.
§Panics
This function panics if the destination doesn’t have the same size as the source. This can happen for dynamically-sized types such as slices.
Sourcepub fn as_raw_ptr(&self) -> *const T
🔬This is a nightly-only experimental API. (sgx_platform #56975)
pub fn as_raw_ptr(&self) -> *const T
sgx_platform #56975)Obtain a raw pointer from this reference.
Sourcepub fn as_raw_mut_ptr(&mut self) -> *mut T
🔬This is a nightly-only experimental API. (sgx_platform #56975)
pub fn as_raw_mut_ptr(&mut self) -> *mut T
sgx_platform #56975)Obtain a raw pointer from this reference.
Sourcepub fn to_enclave(&self) -> T
🔬This is a nightly-only experimental API. (sgx_platform #56975)
pub fn to_enclave(&self) -> T
sgx_platform #56975)Copies the value from user memory into enclave memory.
Trait Implementations§
impl<T: UserSafeSized> Send for User<T>
impl<T: UserSafeSized> Send for User<[T]>
Auto Trait Implementations§
impl<T> !RefUnwindSafe for User<T>
impl<T> !Sync for User<T>
impl<T> !UnwindSafe for User<T>
impl<T> Freeze for User<T>
impl<T> Unpin for User<T>
impl<T> UnsafeUnpin for User<T>
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
Source§impl<T> UserSafeCopyDestination<T> for T
impl<T> UserSafeCopyDestination<T> for T
Source§fn as_mut_ptr(&mut self) -> *mut T
fn as_mut_ptr(&mut self) -> *mut T
sgx_platform #56975)