dynamo_async_openai/traits.rs
1// SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2// SPDX-License-Identifier: Apache-2.0
3//
4// Based on https://github.com/64bit/async-openai/ by Himanshu Neema
5// Original Copyright (c) 2022 Himanshu Neema
6// Licensed under MIT License (see ATTRIBUTIONS-Rust.md)
7//
8// Modifications Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES.
9// Licensed under Apache 2.0
10
11pub trait AsyncTryFrom<T>: Sized {
12 /// The type returned in the event of a conversion error.
13 type Error;
14
15 /// Performs the conversion.
16 fn try_from(value: T) -> impl std::future::Future<Output = Result<Self, Self::Error>> + Send;
17}