1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | |
5 | /// A helper macro for deriving deserialize for an enum to be used in toml-rs. |
6 | /// This macro works be relying on an existing FromStr implementation for the |
7 | /// desired type. |
8 | macro_rules! deserialize_enum_str { |
9 | ($name:ident) => { |
10 | impl<'de> ::serde::Deserialize<'de> for $name { |
11 | fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> |
12 | where |
13 | D: ::serde::Deserializer<'de>, |
14 | { |
15 | struct Visitor; |
16 | impl<'de> ::serde::de::Visitor<'de> for Visitor { |
17 | type Value = $name; |
18 | |
19 | fn expecting(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { |
20 | f.write_str("$name" ) |
21 | } |
22 | |
23 | fn visit_str<E>(self, v: &str) -> Result<$name, E> |
24 | where |
25 | E: ::serde::de::Error, |
26 | { |
27 | match v.parse::<$name>() { |
28 | Ok(v) => Ok(v), |
29 | Err(m) => Err(E::custom(m)), |
30 | } |
31 | } |
32 | } |
33 | deserializer.deserialize_str(Visitor) |
34 | } |
35 | } |
36 | }; |
37 | } |
38 | |
39 | mod bindings; |
40 | mod bitflags; |
41 | mod builder; |
42 | mod cargo; |
43 | mod cdecl; |
44 | mod config; |
45 | mod declarationtyperesolver; |
46 | mod dependencies; |
47 | mod error; |
48 | mod ir; |
49 | mod library; |
50 | mod mangle; |
51 | mod monomorph; |
52 | mod parser; |
53 | mod rename; |
54 | mod reserved; |
55 | mod utilities; |
56 | mod writer; |
57 | |
58 | #[allow (unused)] |
59 | pub(crate) use self::cargo::*; |
60 | |
61 | pub use self::bindings::Bindings; |
62 | pub use self::builder::Builder; |
63 | pub use self::config::Profile; // disambiguate with cargo::Profile |
64 | pub use self::config::*; |
65 | pub use self::error::Error; |
66 | |