Struct tokio_util::sync::ReusableBoxFuture
source · pub struct ReusableBoxFuture<'a, T> { /* private fields */ }
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.
Implementations§
source§impl<'a, T> ReusableBoxFuture<'a, T>
impl<'a, T> ReusableBoxFuture<'a, T>
sourcepub fn new<F>(future: F) -> Selfwhere
F: Future<Output = T> + Send + 'a,
pub fn new<F>(future: F) -> Selfwhere F: Future<Output = T> + Send + 'a,
Create a new ReusableBoxFuture<T>
containing the provided future.
sourcepub fn set<F>(&mut self, future: F)where
F: Future<Output = T> + Send + 'a,
pub fn set<F>(&mut self, future: F)where F: Future<Output = T> + Send + 'a,
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 + 'a,
pub fn try_set<F>(&mut self, future: F) -> Result<(), F>where F: Future<Output = T> + Send + 'a,
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> !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<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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