pub trait AsyncTryInto<T>: Sized {
type Error;
// Required method
fn async_try_into<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = Result<T, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait;
}Expand description
A trait for performing fallible, asynchronous conversions from one type to another.
Similar to TryInto, but with support for asynchronous conversion operations.
Allows a type to be converted into another type, with the possibility of failure,
using an asynchronous method.
§Examples
async fn convert<T: AsyncTryInto>(value: T) -> Result<U, T::Error> { value.async_try_into().await }
Required Associated Types§
Required Methods§
fn async_try_into<'async_trait>(
self,
) -> Pin<Box<dyn Future<Output = Result<T, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
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.
Implementors§
Source§impl<T, U> AsyncTryInto<U> for Twhere
U: AsyncTryFrom<T>,
T: Send,
Provides a generic implementation of AsyncTryInto for types that can be converted
asynchronously using AsyncTryFrom.
impl<T, U> AsyncTryInto<U> for Twhere
U: AsyncTryFrom<T>,
T: Send,
Provides a generic implementation of AsyncTryInto for types that can be converted
asynchronously using AsyncTryFrom.
This implementation allows any type T to be converted into type U if U implements
AsyncTryFrom<T>. The conversion is performed asynchronously and can potentially fail.
§Type Parameters
T: The source type being converted fromU: The target type being converted into
§Constraints
Umust implementAsyncTryFrom<T>Tmust beSend
§Returns
A Result containing the converted value or an error if the conversion fails