rig/client/
verify.rs

1use crate::{
2    http_client,
3    wasm_compat::{WasmBoxedFuture, WasmCompatSend},
4};
5use thiserror::Error;
6
7#[derive(Debug, Error)]
8pub enum VerifyError {
9    #[error("invalid authentication")]
10    InvalidAuthentication,
11    #[error("provider error: {0}")]
12    ProviderError(String),
13    #[error("http error: {0}")]
14    HttpError(
15        #[from]
16        #[source]
17        http_client::Error,
18    ),
19}
20
21/// A provider client that can verify the configuration.
22/// Clone is required for conversions between client types.
23pub trait VerifyClient {
24    /// Verify the configuration.
25    fn verify(&self) -> impl Future<Output = Result<(), VerifyError>> + WasmCompatSend;
26}
27
28#[deprecated(
29    since = "0.25.0",
30    note = "`DynClientBuilder` and related features have been deprecated and will be removed in a future release. In this case, use `VerifyClient` instead."
31)]
32pub trait VerifyClientDyn {
33    /// Verify the configuration.
34    fn verify(&self) -> WasmBoxedFuture<'_, Result<(), VerifyError>>;
35}
36
37#[allow(deprecated)]
38impl<T> VerifyClientDyn for T
39where
40    T: VerifyClient,
41{
42    fn verify(&self) -> WasmBoxedFuture<'_, Result<(), VerifyError>> {
43        Box::pin(self.verify())
44    }
45}