1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/// A helper macro for deriving deserialize for an enum to be used in toml-rs.
/// This macro works be relying on an existing FromStr implementation for the
/// desired type.
macro_rules! deserialize_enum_str {
    ($name:ident) => {
        impl<'de> ::serde::Deserialize<'de> for $name {
            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
            where
                D: ::serde::Deserializer<'de>,
            {
                struct Visitor;
                impl<'de> ::serde::de::Visitor<'de> for Visitor {
                    type Value = $name;

                    fn expecting(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
                        f.write_str("$name")
                    }

                    fn visit_str<E>(self, v: &str) -> Result<$name, E>
                    where
                        E: ::serde::de::Error,
                    {
                        match v.parse::<$name>() {
                            Ok(v) => Ok(v),
                            Err(m) => Err(E::custom(m)),
                        }
                    }
                }
                deserializer.deserialize_str(Visitor)
            }
        }
    };
}

mod bindings;
mod bitflags;
mod builder;
mod cargo;
mod cdecl;
mod config;
mod declarationtyperesolver;
mod dependencies;
mod error;
mod ir;
mod library;
mod mangle;
mod monomorph;
mod parser;
mod rename;
mod reserved;
mod utilities;
mod writer;

#[allow(unused)]
pub(crate) use self::cargo::*;

pub use self::bindings::Bindings;
pub use self::builder::Builder;
pub use self::config::*;
pub use self::error::Error;