veil_macros/
lib.rs

1//! Macros for `veil`
2
3#![warn(missing_docs)]
4
5#[macro_use]
6extern crate quote;
7
8mod enums;
9mod flags;
10mod fmt;
11mod redact;
12mod redactable;
13mod sanitize;
14mod structs;
15
16use proc_macro::TokenStream;
17
18#[proc_macro_derive(Redact, attributes(redact))]
19/// Implements [`Debug`] for a struct or enum, with certain fields redacted.
20///
21/// See the [crate level documentation](index.html) for flags and modifiers.
22pub fn derive_redact(item: TokenStream) -> TokenStream {
23    redact::derive(item)
24}
25
26#[proc_macro_derive(Redactable, attributes(redact))]
27/// Implements [`Redactable`](trait.Redactable.html) for a type.
28///
29/// The type must have a [`Display`](std::fmt::Display) implementation. This is what will be used to redact the type.
30///
31/// See the [crate level documentation](index.html) for flags and modifiers.
32pub fn derive_redactable(item: TokenStream) -> TokenStream {
33    redactable::derive(item)
34}
35
36#[doc(hidden)]
37#[proc_macro]
38/// Used by the `versioning::test_macros_version` test.
39pub fn __private_version(_: TokenStream) -> TokenStream {
40    format!("{:?}", env!("CARGO_PKG_VERSION")).parse().unwrap()
41}