1use url::Url;
2
3mod sealed {
4 use url::Url;
5
6 pub trait Sealed {
7 fn example() -> Self;
8 }
9
10 impl Sealed for Url {
11 fn example() -> Self {
12 Url::parse("https://example.com/path/to/file.pdf").unwrap()
13 }
14 }
15 impl Sealed for String {
16 fn example() -> Self {
17 "path/to/file.pdf".to_string()
18 }
19 }
20}
21
22#[cfg(feature = "serde")]
23pub trait SerdeSupport: serde::Serialize + serde::de::DeserializeOwned {}
24
25#[cfg(not(feature = "serde"))]
26pub trait SerdeSupport {}
27
28#[cfg(feature = "schemars")]
30pub trait SchemaSupport: schemars::JsonSchema {}
31
32#[cfg(not(feature = "schemars"))]
33pub trait SchemaSupport {}
34
35#[cfg(feature = "serde")]
36impl<T> SerdeSupport for T where T: serde::Serialize + serde::de::DeserializeOwned {}
37
38#[cfg(not(feature = "serde"))]
39impl<T> SerdeSupport for T {}
40
41#[cfg(feature = "schemars")]
42impl<T> SchemaSupport for T where T: schemars::JsonSchema {}
43
44#[cfg(not(feature = "schemars"))]
45impl<T> SchemaSupport for T {}
46
47pub trait LocationType: sealed::Sealed + SerdeSupport + SchemaSupport {}
48
49impl LocationType for Url {}
50impl LocationType for String {}