Struct sgx_tstd::boxed::PinBox [−][src]
#[repr(transparent)]pub struct PinBox<T> where
T: ?Sized, { /* fields omitted */ }
pin
)A pinned, heap allocated reference.
Methods
impl<T> PinBox<T>
[src]
impl<T> PinBox<T>
pub fn new(data: T) -> PinBox<T>
[src]
pub fn new(data: T) -> PinBox<T>
pin
)Allocate memory on the heap, move the data into it and pin it.
impl<T> PinBox<T> where
T: ?Sized,
[src]
impl<T> PinBox<T> where
T: ?Sized,
pub fn as_pin_mut(&'a mut self) -> PinMut<'a, T>
[src]
pub fn as_pin_mut(&'a mut self) -> PinMut<'a, T>
pin
)Get a pinned reference to the data in this PinBox.
pub unsafe fn from_raw(raw: *mut T) -> PinBox<T>
[src]
pub unsafe fn from_raw(raw: *mut T) -> PinBox<T>
pin
)Constructs a PinBox
from a raw pointer.
After calling this function, the raw pointer is owned by the
resulting PinBox
. Specifically, the PinBox
destructor will call
the destructor of T
and free the allocated memory. Since the
way PinBox
allocates and releases memory is unspecified, the
only valid pointer to pass to this function is the one taken
from another PinBox
via the PinBox::into_raw
function.
This function is unsafe because improper use may lead to memory problems. For example, a double-free may occur if the function is called twice on the same raw pointer.
Examples
#![feature(pin)] use std::boxed::PinBox; let x = PinBox::new(5); let ptr = PinBox::into_raw(x); let x = unsafe { PinBox::from_raw(ptr) };
pub fn into_raw(b: PinBox<T>) -> *mut T
[src]
pub fn into_raw(b: PinBox<T>) -> *mut T
pin
)Consumes the PinBox
, returning the wrapped raw pointer.
After calling this function, the caller is responsible for the
memory previously managed by the PinBox
. In particular, the
caller should properly destroy T
and release the memory. The
proper way to do so is to convert the raw pointer back into a
PinBox
with the PinBox::from_raw
function.
Note: this is an associated function, which means that you have
to call it as PinBox::into_raw(b)
instead of b.into_raw()
. This
is so that there is no conflict with a method on the inner type.
Examples
#![feature(pin)] use std::boxed::PinBox; let x = PinBox::new(5); let ptr = PinBox::into_raw(x);
pub unsafe fn get_mut(this: &'a mut PinBox<T>) -> &'a mut T
[src]
pub unsafe fn get_mut(this: &'a mut PinBox<T>) -> &'a mut T
pin
)Get a mutable reference to the data inside this PinBox.
This function is unsafe. Users must guarantee that the data is never moved out of this reference.
ⓘImportant traits for Box<I>pub unsafe fn unpin(this: PinBox<T>) -> Box<T>
[src]
pub unsafe fn unpin(this: PinBox<T>) -> Box<T>
pin
)Convert this PinBox into an unpinned Box.
This function is unsafe. Users must guarantee that the data is never moved out of the box.
Trait Implementations
impl<T> Pointer for PinBox<T> where
T: ?Sized,
[src]
impl<T> Pointer for PinBox<T> where
T: ?Sized,
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter.
impl<T> DerefMut for PinBox<T> where
T: Unpin + ?Sized,
[src]
impl<T> DerefMut for PinBox<T> where
T: Unpin + ?Sized,
impl<'a, T, F> UnsafeFutureObj<'a, T> for PinBox<F> where
F: Future<Output = T> + 'a,
[src]
impl<'a, T, F> UnsafeFutureObj<'a, T> for PinBox<F> where
F: Future<Output = T> + 'a,
fn into_raw(self) -> *mut ()
[src]
fn into_raw(self) -> *mut ()
🔬 This is a nightly-only experimental API. (futures_api
)
futures in libcore are unstable
Convert an owned instance into a (conceptually owned) void pointer.
unsafe fn poll(ptr: *mut (), cx: &mut Context) -> Poll<T>
[src]
unsafe fn poll(ptr: *mut (), cx: &mut Context) -> Poll<T>
🔬 This is a nightly-only experimental API. (futures_api
)
futures in libcore are unstable
Poll the future represented by the given void pointer. Read more
unsafe fn drop(ptr: *mut ())
[src]
unsafe fn drop(ptr: *mut ())
🔬 This is a nightly-only experimental API. (futures_api
)
futures in libcore are unstable
Drops the future represented by the given void pointer. Read more
impl<F> Future for PinBox<F> where
F: Future + ?Sized,
[src]
impl<F> Future for PinBox<F> where
F: Future + ?Sized,
type Output = <F as Future>::Output
🔬 This is a nightly-only experimental API. (futures_api
)
futures in libcore are unstable
The result of the Future
.
fn poll(
self: PinMut<PinBox<F>>,
cx: &mut Context
) -> Poll<<PinBox<F> as Future>::Output>
[src]
fn poll(
self: PinMut<PinBox<F>>,
cx: &mut Context
) -> Poll<<PinBox<F> as Future>::Output>
🔬 This is a nightly-only experimental API. (futures_api
)
futures in libcore are unstable
Attempt to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more
impl<T> Debug for PinBox<T> where
T: Debug + ?Sized,
[src]
impl<T> Debug for PinBox<T> where
T: Debug + ?Sized,
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter. Read more
impl<T> Deref for PinBox<T> where
T: ?Sized,
[src]
impl<T> Deref for PinBox<T> where
T: ?Sized,
type Target = T
The resulting type after dereferencing.
fn deref(&self) -> &T
[src]
fn deref(&self) -> &T
Dereferences the value.
impl<T> From<Box<T>> for PinBox<T> where
T: ?Sized,
[src]
impl<T> From<Box<T>> for PinBox<T> where
T: ?Sized,
impl<'a, F> From<PinBox<F>> for FutureObj<'a, ()> where
F: 'a + Send + Future<Output = ()>,
[src]
impl<'a, F> From<PinBox<F>> for FutureObj<'a, ()> where
F: 'a + Send + Future<Output = ()>,
impl<'a, F> From<PinBox<F>> for LocalFutureObj<'a, ()> where
F: 'a + Future<Output = ()>,
[src]
impl<'a, F> From<PinBox<F>> for LocalFutureObj<'a, ()> where
F: 'a + Future<Output = ()>,
fn from(boxed: PinBox<F>) -> LocalFutureObj<'a, ()>
[src]
fn from(boxed: PinBox<F>) -> LocalFutureObj<'a, ()>
Performs the conversion.
impl<T> From<PinBox<T>> for Box<T> where
T: Unpin + ?Sized,
[src]
impl<T> From<PinBox<T>> for Box<T> where
T: Unpin + ?Sized,
impl<T> Unpin for PinBox<T> where
T: ?Sized,
[src]
impl<T> Unpin for PinBox<T> where
T: ?Sized,
impl<T, U> CoerceUnsized<PinBox<U>> for PinBox<T> where
T: Unsize<U> + ?Sized,
U: ?Sized,
[src]
impl<T, U> CoerceUnsized<PinBox<U>> for PinBox<T> where
T: Unsize<U> + ?Sized,
U: ?Sized,
impl<T> Display for PinBox<T> where
T: Display + ?Sized,
[src]
impl<T> Display for PinBox<T> where
T: Display + ?Sized,