use crate::{env::internal::Env, Error, TryFromVal};
use core::fmt::Debug;
#[doc(hidden)]
#[deprecated(
note = "TryFromValForContractFn is an internal trait and is not safe to use or implement"
)]
pub trait TryFromValForContractFn<E: Env, V: ?Sized>: Sized {
type Error: Debug + Into<Error>;
fn try_from_val_for_contract_fn(env: &E, v: &V) -> Result<Self, Self::Error>;
}
#[cfg(feature = "experimental_spec_shaking_v2")]
#[doc(hidden)]
#[allow(deprecated)]
impl<E: Env, T, U> TryFromValForContractFn<E, T> for U
where
U: TryFromVal<E, T> + crate::SpecShakingMarker,
{
type Error = U::Error;
fn try_from_val_for_contract_fn(e: &E, v: &T) -> Result<Self, Self::Error> {
U::spec_shaking_marker();
U::try_from_val(e, v)
}
}
#[cfg(not(feature = "experimental_spec_shaking_v2"))]
#[doc(hidden)]
#[allow(deprecated)]
impl<E: Env, T, U> TryFromValForContractFn<E, T> for U
where
U: TryFromVal<E, T>,
{
type Error = U::Error;
fn try_from_val_for_contract_fn(e: &E, v: &T) -> Result<Self, Self::Error> {
U::try_from_val(e, v)
}
}