pub trait AsyncAccepts<Value> {
// Required method
fn accept_async<'a>(&'a self, value: Value) -> impl Future<Output = ()> + 'a
where Value: 'a;
}Expand description
Receives a value and returns a future that completes once processing finishes.
This mirrors Accepts for asynchronous scenarios where the
acceptor must yield until some work is done. The returned future is tied to
the lifetime of self, making it straightforward to borrow state inside the
async body.
use accepts::AsyncAccepts;
use core::future::Future;
struct AsyncPrinter;
impl AsyncAccepts<String> for AsyncPrinter {
fn accept_async<'a>(&'a self, value: String) -> impl Future<Output = ()> + 'a
where
String: 'a,
{
async move {
println!("{}", value);
}
}
}
let printer = AsyncPrinter;
printer
.accept_async(String::from("Hello, async world!"))
.await;Required Methods§
fn accept_async<'a>(&'a self, value: Value) -> impl Future<Output = ()> + 'awhere
Value: 'a,
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<T: AsyncAccepts<Value> + ?Sized, Value> AsyncAccepts<Value> for &T
impl<T: AsyncAccepts<Value> + ?Sized, Value> AsyncAccepts<Value> for &T
fn accept_async<'a>(&'a self, value: Value) -> impl Future<Output = ()> + 'awhere
Value: 'a,
Source§impl<T: AsyncAccepts<Value> + ?Sized, Value> AsyncAccepts<Value> for &mut T
impl<T: AsyncAccepts<Value> + ?Sized, Value> AsyncAccepts<Value> for &mut T
fn accept_async<'a>(&'a self, value: Value) -> impl Future<Output = ()> + 'awhere
Value: 'a,
Source§impl<T: AsyncAccepts<Value> + ?Sized, Value> AsyncAccepts<Value> for Box<T>
Available on crate feature alloc only.
impl<T: AsyncAccepts<Value> + ?Sized, Value> AsyncAccepts<Value> for Box<T>
Available on crate feature
alloc only.fn accept_async<'a>(&'a self, value: Value) -> impl Future<Output = ()> + 'awhere
Value: 'a,
Source§impl<T: AsyncAccepts<Value> + ?Sized, Value> AsyncAccepts<Value> for Rc<T>
Available on crate feature alloc only.
impl<T: AsyncAccepts<Value> + ?Sized, Value> AsyncAccepts<Value> for Rc<T>
Available on crate feature
alloc only.fn accept_async<'a>(&'a self, value: Value) -> impl Future<Output = ()> + 'awhere
Value: 'a,
Source§impl<T: AsyncAccepts<Value> + ?Sized, Value> AsyncAccepts<Value> for Arc<T>
Available on crate feature alloc only.
impl<T: AsyncAccepts<Value> + ?Sized, Value> AsyncAccepts<Value> for Arc<T>
Available on crate feature
alloc only.