cbindgen/bindgen/
mod.rs

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;
48#[cfg(feature = "unstable_ir")]
49pub mod ir;
50#[cfg(not(feature = "unstable_ir"))]
51mod ir;
52mod language_backend;
53mod library;
54mod mangle;
55mod monomorph;
56mod parser;
57mod rename;
58mod reserved;
59mod utilities;
60mod writer;
61
62#[allow(unused)]
63pub(crate) use self::cargo::*;
64
65pub use self::bindings::Bindings;
66pub use self::builder::Builder;
67pub use self::config::Profile; // disambiguate with cargo::Profile
68pub use self::config::*;
69pub use self::error::Error;