Struct tokio_util::sync::ReusableBoxFuture
source · pub struct ReusableBoxFuture<'a, T> {
boxed: Pin<Box<dyn Future<Output = T> + Send + 'a>>,
}
Expand description
A reusable Pin<Box<dyn Future<Output = T> + Send + 'a>>
.
This type lets you replace the future stored in the box without reallocating when the size and alignment permits this.
Fields§
§boxed: Pin<Box<dyn Future<Output = T> + Send + 'a>>
Implementations§
source§impl<'a, T> ReusableBoxFuture<'a, T>
impl<'a, T> ReusableBoxFuture<'a, T>
sourcepub fn new<F>(future: F) -> Self
pub fn new<F>(future: F) -> Self
Create a new ReusableBoxFuture<T>
containing the provided future.
sourcepub fn set<F>(&mut self, future: F)
pub fn set<F>(&mut self, future: F)
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>
pub fn try_set<F>(&mut self, future: F) -> Result<(), F>
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§
source§impl<T> Debug for ReusableBoxFuture<'_, T>
impl<T> Debug for ReusableBoxFuture<'_, T>
source§impl<T> Future for ReusableBoxFuture<'_, T>
impl<T> Future for ReusableBoxFuture<'_, T>
impl<T> Sync for ReusableBoxFuture<'_, T>
Auto Trait Implementations§
impl<'a, T> Freeze for ReusableBoxFuture<'a, T>
impl<'a, T> !RefUnwindSafe for ReusableBoxFuture<'a, T>
impl<'a, T> Send for ReusableBoxFuture<'a, T>
impl<'a, T> Unpin for ReusableBoxFuture<'a, T>
impl<'a, T> !UnwindSafe for ReusableBoxFuture<'a, 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
Mutably borrows from an owned value. Read more
source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
§type IntoFuture = F
type IntoFuture = F
Which kind of future are we turning this into?
source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
Creates a future from a value. Read more