Expand description
Derive-deftly macro for deriving configuration objects.
The macro defined here makes a configuration object able to participate in the arti configuration system by giving it a Builder type implementing the appropriate serde traits.
It is more ergonomic and less error-prone for our purposes than
derive_builder.
§Basic usage:
use derive_deftly::Deftly;
use tor_config::derive::prelude::*;
#[derive(Deftly, Clone, Debug, PartialEq)]
#[derive_deftly(TorConfig)]
pub struct ExampleConfig {
#[deftly(tor_config(default))]
owner_uid: Option<u32>,
#[deftly(tor_config(default = r#" "~".to_string() "#))]
path: String,
}For topic-specific information, see one of the following:
Modules§
- doc_
differences - Differences from
derive_builder - doc_
generated_ code - Code generated by the tor_config macro
- doc_
howto - How to declare a configuration type
- doc_
magic_ types - Types with “magic” handling
- doc_
ref_ attrs - Reference: Attributes supported by the tor_config macro
- prelude
- Module to import in order to use the tor_config template.
- seal 🔒
- Helper for sealing traits below.
Macros§
- assert_
not_ impl - Give a compile time error if the type $t implements $trait.
- derive_
deftly_ template_ TorConfig - Define a builder type for a given type, with settings appropriate to participate in the Arti build system.
- impl_
many 🔒 - Implement each
traitfor every comma-separated type intypes, with an empty body. - should_
not_ 🔒be_ used_ in_ collection - Declare that types shouldn’t be used in a collection (because they would want magic serde handling, but that isn’t implemented).
Traits§
- Should
BeCaught AsSerde Special Case - A trait implemented by all the types that should receive automatic serde magic handling.
- Should
BeCaught AsSpecial Case - A trait implemented by all the types that
normalize_and_invokedoes anything magic for. - Should
NotBe Used - A trait implemented by types that we shouldn’t actually use as fields in a configuration.
- Should
UseList Builder - A trait implemented by the types for which we should recommend the use of a list builder.
- Should
UseMap Builder - A trait implemented by the types for which we should recommend the use of a map builder.