[−][src]Struct std::os::fortanix_sgx::usercalls::alloc::User
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
impl<T: ?Sized> User<T> where
T: UserSafe,
[src]
T: UserSafe,
pub fn new_from_enclave(val: &T) -> Self
[src]
Copies val
into freshly allocated space in user memory.
pub unsafe fn from_raw(ptr: *mut T) -> Self
[src]
Creates an owned User<T>
from a raw pointer.
Safety
The caller must ensure ptr
points to 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 is not in user memory
pub fn into_raw(self) -> *mut T
[src]
Converts this value into a raw pointer. The value will no longer be automatically freed.
impl<T> User<T> where
T: UserSafe,
[src]
T: UserSafe,
impl<T> User<[T]> where
[T]: UserSafe,
[src]
[T]: UserSafe,
pub fn uninitialized(n: usize) -> Self
[src]
Allocate space for a [T]
of n
elements in user memory.
pub unsafe fn from_raw_parts(ptr: *mut T, len: usize) -> Self
[src]
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>>
pub fn copy_from_enclave(&mut self, val: &T)
[src]
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.
pub fn copy_to_enclave(&self, dest: &mut T)
[src]
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.
pub fn as_raw_ptr(&self) -> *const T
[src]
Obtain a raw pointer from this reference.
pub fn as_raw_mut_ptr(&mut self) -> *mut T
[src]
Obtain a raw pointer from this reference.
pub fn as_ptr(&self) -> *const T
[src]
Obtain a raw pointer to the first element of this user slice.
pub fn as_mut_ptr(&mut self) -> *mut T
[src]
Obtain a raw pointer to the first element of this user slice.
pub fn len(&self) -> usize
[src]
Obtain the number of elements in this user slice.
pub fn copy_to_enclave_vec(&self, dest: &mut Vec<T>)
[src]
Copies the value from user memory and place it into dest
. Afterwards,
dest
will contain exactly self.len()
elements.
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.
pub fn to_enclave(&self) -> Vec<T>
[src]
Copies the value from user memory into a vector in enclave memory.
pub fn iter(&self) -> Iter<T> where
T: UserSafe,
[src]
T: UserSafe,
Returns an iterator over the slice.
pub fn iter_mut(&mut self) -> IterMut<T> where
T: UserSafe,
[src]
T: UserSafe,
Returns an iterator that allows modifying each value.
pub fn copy_user_buffer(&self) -> Vec<u8>
[src]
Copies the user memory range pointed to by the user ByteBuffer
to
enclave memory.
Panics
This function panics if, in the user ByteBuffer
:
- The pointer is null
- The pointed-to range does not fit in the address space
- The pointed-to range is not in user memory
Trait Implementations
impl<T: ?Sized> Deref for User<T> where
T: UserSafe,
[src]
T: UserSafe,
type Target = UserRef<T>
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
impl<T: ?Sized> DerefMut for User<T> where
T: UserSafe,
[src]
T: UserSafe,
impl<T: ?Sized> Drop for User<T> where
T: UserSafe,
[src]
T: UserSafe,
Auto Trait Implementations
impl<T> !RefUnwindSafe for User<T>
impl<T> !Send for User<T>
impl<T> !Sync for User<T>
impl<T: ?Sized> Unpin for User<T>
impl<T> !UnwindSafe for User<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,