Skip to main content

Module derive

Module derive 

Source
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 trait for every comma-separated type in types, 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§

ShouldBeCaughtAsSerdeSpecialCase
A trait implemented by all the types that should receive automatic serde magic handling.
ShouldBeCaughtAsSpecialCase
A trait implemented by all the types that normalize_and_invoke does anything magic for.
ShouldNotBeUsed
A trait implemented by types that we shouldn’t actually use as fields in a configuration.
ShouldUseListBuilder
A trait implemented by the types for which we should recommend the use of a list builder.
ShouldUseMapBuilder
A trait implemented by the types for which we should recommend the use of a map builder.