Struct tokio_util::sync::ReusableBoxFuture
source · [−]pub struct ReusableBoxFuture<T> { /* private fields */ }
Expand description
A reusable Pin<Box<dyn Future<Output = T> + Send>>
.
This type lets you replace the future stored in the box without reallocating when the size and alignment permits this.
Implementations
sourceimpl<T> ReusableBoxFuture<T>
impl<T> ReusableBoxFuture<T>
sourcepub fn new<F>(future: F) -> Self where
F: Future<Output = T> + Send + 'static,
pub fn new<F>(future: F) -> Self where
F: Future<Output = T> + Send + 'static,
Create a new ReusableBoxFuture<T>
containing the provided future.
sourcepub fn set<F>(&mut self, future: F) where
F: Future<Output = T> + Send + 'static,
pub fn set<F>(&mut self, future: F) where
F: Future<Output = T> + Send + 'static,
Replace the future currently stored in this box.
This reallocates if and only if the layout of the provided future is different from the layout of the currently stored future.
sourcepub fn try_set<F>(&mut self, future: F) -> Result<(), F> where
F: Future<Output = T> + Send + 'static,
pub fn try_set<F>(&mut self, future: F) -> Result<(), F> where
F: Future<Output = T> + Send + 'static,
Replace the future currently stored in this box.
This function never reallocates, but returns an error if the provided future has a different size or alignment from the currently stored future.
Trait Implementations
sourceimpl<T> Debug for ReusableBoxFuture<T>
impl<T> Debug for ReusableBoxFuture<T>
sourceimpl<T> Drop for ReusableBoxFuture<T>
impl<T> Drop for ReusableBoxFuture<T>
sourceimpl<T> Future for ReusableBoxFuture<T>
impl<T> Future for ReusableBoxFuture<T>
impl<T> Send for ReusableBoxFuture<T>
impl<T> Sync for ReusableBoxFuture<T>
impl<T> Unpin for ReusableBoxFuture<T>
Auto Trait Implementations
impl<T> !RefUnwindSafe for ReusableBoxFuture<T>
impl<T> !UnwindSafe for ReusableBoxFuture<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<F> IntoFuture for F where
F: Future,
impl<F> IntoFuture for F where
F: Future,
type Output = <F as Future>::Output
type Output = <F as Future>::Output
into_future
)The output that the future will produce on completion.
type IntoFuture = F
type IntoFuture = F
into_future
)Which kind of future are we turning this into?
sourcefn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
into_future
)Creates a future from a value. Read more