1mod api;
2pub use api::*;
3
4#[cfg(test)]
5mod tests {
6    use super::*;
7    use std::error::Error;
8
9    struct Source(String);
11    struct Target(String);
12
13    #[async_trait::async_trait]
14    impl AsyncTryFrom<Source> for Target {
15        type Error = Box<dyn Error + Send + Sync>;
16
17        async fn async_try_from(value: Source) -> Result<Self, Self::Error> {
18            Ok(Target(value.0))
19        }
20    }
21
22    #[tokio::test]
23    async fn test_async_try_from() {
24        let source = Source("test data".to_string());
26        let result = Target::async_try_from(source).await;
27        assert!(result.is_ok());
28        assert_eq!(result.unwrap().0, "test data");
29    }
30
31    #[tokio::test]
32    async fn test_async_try_into() {
33        let source = Source("convert me".to_string());
35        let result: Result<Target, _> = source.async_try_into().await;
36        assert!(result.is_ok());
37        assert_eq!(result.unwrap().0, "convert me");
38    }
39
40    #[tokio::test]
41    async fn test_identity_conversion() {
42        let original = "test string".to_string();
44        let result: Result<String, _> = original.clone().async_try_into().await;
45        assert!(result.is_ok());
46        assert_eq!(result.unwrap(), original);
47    }
48
49    }