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.
8macro_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
39mod bindings;
40mod bitflags;
41mod builder;
42mod cargo;
43mod cdecl;
44mod config;
45mod declarationtyperesolver;
46mod dependencies;
47mod error;
48mod ir;
49mod library;
50mod mangle;
51mod monomorph;
52mod parser;
53mod rename;
54mod reserved;
55mod utilities;
56mod writer;
57
58#[allow(unused)]
59pub(crate) use self::cargo::*;
60
61pub use self::bindings::Bindings;
62pub use self::builder::Builder;
63pub use self::config::Profile; // disambiguate with cargo::Profile
64pub use self::config::*;
65pub use self::error::Error;
66