Skip to main content

coda_api/ext/
parse_rich_value.rs

1mod impl_try_from_rich_value_for_string;
2
3pub use impl_try_from_rich_value_for_string::*;
4
5mod impl_try_from_rich_value_for_f64;
6
7pub use impl_try_from_rich_value_for_f64::*;
8
9mod impl_try_from_rich_value_for_bool;
10
11pub use impl_try_from_rich_value_for_bool::*;
12
13mod impl_try_from_rich_value_for_option_bool;
14
15pub use impl_try_from_rich_value_for_option_bool::*;
16
17#[cfg(feature = "time")]
18mod impl_try_from_rich_value_for_option_duration;
19
20#[cfg(feature = "time")]
21pub use impl_try_from_rich_value_for_option_duration::*;
22
23#[cfg(feature = "time")]
24mod impl_try_from_rich_value_for_option_offset_date_time;
25
26#[cfg(feature = "time")]
27pub use impl_try_from_rich_value_for_option_offset_date_time::*;
28
29mod impl_try_from_rich_value_for_rich_row_reference;
30
31pub use impl_try_from_rich_value_for_rich_row_reference::*;
32
33pub fn normalize_rich_string(value: &str) -> String {
34    if let Some(stripped) = value
35        .strip_prefix("```")
36        .and_then(|inner| inner.strip_suffix("```"))
37    {
38        stripped.to_string()
39    } else {
40        value.to_string()
41    }
42}
43
44pub fn normalize_owned_rich_string(value: String) -> String {
45    if value.len() >= 6 && value.starts_with("```") && value.ends_with("```") {
46        value[3..value.len() - 3].to_string()
47    } else {
48        value
49    }
50}