soroban_sdk/
arbitrary_extra.rs

1//! Extra trait impls required by the bounds to `SorobanArbitrary`.
2//!
3//! These are in their own module so that they are defined even when "testutils"
4//! is not configured, making type inference consistent between configurations.
5
6use crate::ConversionError;
7use crate::Error;
8use crate::{Env, TryFromVal};
9
10impl TryFromVal<Env, u32> for u32 {
11    type Error = ConversionError;
12    fn try_from_val(_env: &Env, v: &u32) -> Result<Self, Self::Error> {
13        Ok(*v)
14    }
15}
16
17impl TryFromVal<Env, i32> for i32 {
18    type Error = ConversionError;
19    fn try_from_val(_env: &Env, v: &i32) -> Result<Self, Self::Error> {
20        Ok(*v)
21    }
22}
23
24impl TryFromVal<Env, u64> for u64 {
25    type Error = ConversionError;
26    fn try_from_val(_env: &Env, v: &u64) -> Result<Self, Self::Error> {
27        Ok(*v)
28    }
29}
30
31impl TryFromVal<Env, i64> for i64 {
32    type Error = ConversionError;
33    fn try_from_val(_env: &Env, v: &i64) -> Result<Self, Self::Error> {
34        Ok(*v)
35    }
36}
37
38impl TryFromVal<Env, u128> for u128 {
39    type Error = ConversionError;
40    fn try_from_val(_env: &Env, v: &u128) -> Result<Self, Self::Error> {
41        Ok(*v)
42    }
43}
44
45impl TryFromVal<Env, i128> for i128 {
46    type Error = ConversionError;
47    fn try_from_val(_env: &Env, v: &i128) -> Result<Self, Self::Error> {
48        Ok(*v)
49    }
50}
51
52impl TryFromVal<Env, bool> for bool {
53    type Error = ConversionError;
54    fn try_from_val(_env: &Env, v: &bool) -> Result<Self, Self::Error> {
55        Ok(*v)
56    }
57}
58
59impl TryFromVal<Env, ()> for () {
60    type Error = ConversionError;
61    fn try_from_val(_env: &Env, v: &()) -> Result<Self, Self::Error> {
62        Ok(*v)
63    }
64}
65
66impl TryFromVal<Env, Error> for Error {
67    type Error = ConversionError;
68    fn try_from_val(_env: &Env, v: &Error) -> Result<Self, Self::Error> {
69        Ok(*v)
70    }
71}