std::future::UnsafeFutureObj - Rust
Description: API documentation for the Rust `UnsafeFutureObj` trait in crate `std`.
Keywords: rust, rustlang, rust-lang, UnsafeFutureObj

# [−][src]Trait std::future::UnsafeFutureObj

    pub unsafe trait UnsafeFutureObj<'a, T>: 'a {
        fn into_raw(self) -> *mut ();
        unsafe fn poll(ptr: *mut (), cx: &mut Context) -> Poll<T>;
        unsafe fn drop(ptr: *mut ());
    }

🔬 This is a nightly-only experimental API. (`futures_api` #50547)

futures in libcore are unstable

A custom implementation of a future trait object for `FutureObj`, providing a hand-rolled vtable.

This custom representation is typically used only in `no_std` contexts, where the default `Box`-based implementation is not available.

The implementor must guarantee that it is safe to call `poll` repeatedly (in a non-concurrent fashion) with the result of `into_raw` until `drop` is called.

## Required Methods

### `fn into_raw(self) -> *mut ()`

🔬 This is a nightly-only experimental API. (`futures_api` #50547)

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>`

🔬 This is a nightly-only experimental API. (`futures_api` #50547)

futures in libcore are unstable

Poll the future represented by the given void pointer.

# Safety

The trait implementor must guarantee that it is safe to repeatedly call `poll` with the result of `into_raw` until `drop` is called; such calls are not, however, allowed to race with each other or with calls to `drop`.

### `unsafe fn drop(ptr: *mut ())`

🔬 This is a nightly-only experimental API. (`futures_api` #50547)

futures in libcore are unstable

Drops the future represented by the given void pointer.

# Safety

The trait implementor must guarantee that it is safe to call this function once per `into_raw` invocation; that call cannot race with other calls to `drop` or `poll`.

## Implementors

###

`impl<'a, T, F> UnsafeFutureObj<'a, T> for &'a mut F where F: Future<Output = T> + Unpin + 'a,`

[src]

####

`fn into_raw(self) -> *mut ()`

[src]

🔬 This is a nightly-only experimental API. (`futures_api` #50547)

futures in libcore are unstable

####

`unsafe fn poll(ptr: *mut (), cx: &mut Context) -> Poll<T>`

[src]

🔬 This is a nightly-only experimental API. (`futures_api` #50547)

futures in libcore are unstable

####

`unsafe fn drop(_ptr: *mut ())`

[src]

🔬 This is a nightly-only experimental API. (`futures_api` #50547)

futures in libcore are unstable

###

`impl<'a, T, F> UnsafeFutureObj<'a, T> for Box<F> where F: Future<Output = T> + 'a,`

[src]

####

`fn into_raw(self) -> *mut ()`

[src]

🔬 This is a nightly-only experimental API. (`futures_api` #50547)

futures in libcore are unstable

####

`unsafe fn poll(ptr: *mut (), cx: &mut Context) -> Poll<T>`

[src]

🔬 This is a nightly-only experimental API. (`futures_api` #50547)

futures in libcore are unstable

####

`unsafe fn drop(ptr: *mut ())`

[src]

🔬 This is a nightly-only experimental API. (`futures_api` #50547)

futures in libcore are unstable

###

`impl<'a, T, F> UnsafeFutureObj<'a, T> for PinBox<F> where F: Future<Output = T> + 'a,`

[src]

####

`fn into_raw(self) -> *mut ()`

[src]

🔬 This is a nightly-only experimental API. (`futures_api` #50547)

futures in libcore are unstable

####

`unsafe fn poll(ptr: *mut (), cx: &mut Context) -> Poll<T>`

[src]

🔬 This is a nightly-only experimental API. (`futures_api` #50547)

futures in libcore are unstable

####

`unsafe fn drop(ptr: *mut ())`

[src]

🔬 This is a nightly-only experimental API. (`futures_api` #50547)

futures in libcore are unstable

###

`impl<'a, T, F> UnsafeFutureObj<'a, T> for PinMut<'a, F> where F: Future<Output = T> + 'a,`

[src]

####

`fn into_raw(self) -> *mut ()`

[src]

🔬 This is a nightly-only experimental API. (`futures_api` #50547)

futures in libcore are unstable

####

`unsafe fn poll(ptr: *mut (), cx: &mut Context) -> Poll<T>`

[src]

🔬 This is a nightly-only experimental API. (`futures_api` #50547)

futures in libcore are unstable

####

`unsafe fn drop(_ptr: *mut ())`

[src]

🔬 This is a nightly-only experimental API. (`futures_api` #50547)

futures in libcore are unstable

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g. `str,u8` or `String,struct:Vec,test`)