actix_prost_convert_trait/
lib.rs1use std::fmt::Display;
2
3mod impls;
4
5#[cfg(feature = "conv-address")]
6mod address;
7
8#[cfg(feature = "conv-hash")]
9mod hash;
10
11#[cfg(feature = "conv-bytes")]
12mod bytes;
13
14#[cfg(feature = "conv-url")]
15mod url;
16
17#[cfg(feature = "conv-datetime")]
18mod datetime;
19
20#[cfg(feature = "conv-uuid")]
21mod uuid;
22
23#[cfg(feature = "conv-ip")]
24mod ip;
25
26#[cfg(feature = "conv-path")]
27mod path;
28
29#[cfg(feature = "conv-duration")]
30mod duration;
31
32#[cfg(feature = "conv-decimal")]
33mod decimal;
34
35pub trait TryConvert<T>: Sized {
36 fn try_convert(value: T) -> Result<Self, String>;
37}
38
39pub fn failed_to_parse_error_message_with_description(
40 value: impl Display,
41 type_name: impl Display,
42 error_description: impl Display,
43) -> String {
44 format!(
45 "failed to parse '{}' as {}: {}",
46 value, type_name, error_description
47 )
48}
49
50pub fn failed_to_parse_error_message(value: impl Display, type_name: impl Display) -> String {
51 format!("failed to parse '{}' as {}", value, type_name)
52}