aboutsummaryrefslogtreecommitdiff
path: root/crates/tor-config/src/list_builder.rs
Commit message (Collapse)AuthorAgeFilesLines
* maint: Run maint/add_warning to deny string slicesClara Engler2026-06-091-0/+1
| | | | | | | | | | | | This commit executes maint/add_warning with the just added change to deny string slices except in tests. I recommend auditing this by checking out the previous commit followed by running the script yourself and then verifying that the diff is identical to this commit. This commit makes cargo clippy fail. We will add exceptions in the next commit.
* config: Update doctests to use Deftly, and to passNick Mathewson2026-05-271-0/+3
| | | | | | | | Some of the tests used derive(Builder), which is not current practice for our configuration. Additionally, they didn't implement the requisite ConfigBuilder logic to pass with the other changes in this branch.
* config: Add a method to fill in a builder with unset defaultsNick Mathewson2026-05-271-0/+27
| | | | | | | | | | | | | | | This new method modifies a builder by replacing any unset values that have a default with that default. We're using this method so that we can re-serialize a builder into a `ConfigurationTree` with all of its default values included. In all cases, `b.apply_defaults()?; b.build()` should produce the same output as `b.build()`. The interesting parts of this commit are in tor_config::load and tor_config::derive. The rest of this commit just adds `apply_defaults` to other builders that _aren't_ made with `derive_deftly(TorConfig)`.
* config: Implement Builder for ListBuilders and MapBuilders.Nick Mathewson2026-05-271-0/+9
| | | | This isn't strictly necessary, but it helps for consistency.
* tor_config: Make ListBuilders implement ExtendBuilder.Nick Mathewson2025-12-091-0/+11
|
* tor-config: missing #[allow(dead_code)] in derive_list_builder_helperNick Mathewson2025-12-091-0/+1
|
* tor-config: missing $crate in derive_list_builder_helperNick Mathewson2025-12-091-1/+1
|
* tor-config: obviate need for Educe in derive_list_builder_helperNick Mathewson2025-12-091-2/+11
| | | | | | We were only using it for Default, and it is easier to implement Default by hand than it is to keep this particular layer in our leaning tower of macros.
* Fix name of clippy lint to unchecked_time_subtraction (2)Ian Jackson2025-11-061-1/+1
| | | | Run maint/add_warning
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-071-1/+4
| | | | | | | | | | | | | | First, run ``` git grep -l "^edition =" | xargs perl -i -pe 's/^edition *=.*/edition = "2024"/;' ``` Second, manually verify that all Cargo.toml files have changed, and nothing else has changed. Third, run cargo fmt again.
* list_builder: fix a very typoed line.Nick Mathewson2024-12-191-1/+1
|
* Merge branch 'encapsulate_config_rs' into 'main'Nick Mathewson2024-03-131-4/+4
|\ | | | | | | | | Encapsulate usage of config-rs inside tor-config. See merge request tpo/core/arti!2040
| * tor_config: Hide macro-only re-exports.Nick Mathewson2024-03-131-4/+4
| | | | | | | | | | Our macros use these exports, but we don't need everybody else to be able to see them.
* | Run maint/add_warning.Nick Mathewson2024-03-131-0/+1
|/
* educe: Use std's default for enums where default variant is unitIan Jackson2024-02-121-3/+2
| | | | | | | | | | | | | Since Rust 1.66, std's default works properly for enums, provided that the default variant is a unit. Review all uses of `#[educe(default)]` on enums and replace them with std where possible, which is most of them. In 1.66 and later, std's `#[derive(Default)]` doesn't infer any generic bounds on the derived impl, where it's an enum - since the unit variant can always be constructed. So this change doesn't add any generic bounds and is not API-visible.
* Run maint/add_warning to add lint block everywhereIan Jackson2023-08-231-0/+1
|
* Run maint/add_warning to actually apply new lint allowsIan Jackson2023-07-101-0/+1
|
* Allow clippy::unchecked_duration_subtraction in testsNick Mathewson2023-01-271-0/+1
| | | | | This panics on error, and we're fine with a panic on misbehavior in tests.
* tor-basic-utils: list_builder: Use standard test lint blockIan Jackson2022-11-291-0/+8
| | | | This gets rid of a spurious warning on nightly about the use of dbg!
* tor-config MultilineListBuilder: Test deserialisationIan Jackson2022-11-291-0/+45
|
* tor-config MultilineListBuilder: Print line number starting at 1, not 0Ian Jackson2022-11-291-1/+1
|
* tor-config list_builder tests: Move Outer up a levelIan Jackson2022-11-291-19/+19
| | | | We're going to reuse this.
* MultilineListBuilder: Use a manual implementation of DeserializeIan Jackson2022-11-291-2/+52
| | | | | | The error message from `#[serde(untagged)]` would otherwise start to appear when we try to deserialise unsupported PT configurations, when compiled with bridge but not PT support.
* Make the bridge list in the builder be a list of BridgeConfigBuilderIan Jackson2022-11-211-26/+24
| | | | By changing MultilineListBuilder.
* tor-basic-utils: list_builder: Introduce DirectDefaultEmptyListBuilderAccessorsIan Jackson2022-11-211-0/+63
| | | | | This trait can have this ludicrously long name because no-one needs to import it.
* tor-config: Provide MultilineListBuilderIan Jackson2022-10-121-0/+207
| | | | This is what we'll use to parse the `bridges.bridges` config key.
* tor-config: Remove unneeded braces in an exampleIan Jackson2022-10-121-1/+1
|
* tor_config: define_list_builder_helper: Support custom serdeIan Jackson2022-10-121-2/+42
| | | | | | | | We're going to want something that has the standard list builder methods at the Rust API, but which has different serialisation. Sadly the implementation is annoying, because macro_rules makes it hard to parse a nice input syntax.
* fix nighly clippytrinity-1686a2022-07-231-4/+4
|
* Merge branch 'config-test' into 'main'Ian Jackson2022-05-311-2/+1
|\ | | | | | | | | arti config: Check that example config is exhaustive See merge request tpo/core/arti!546
| * tor-config: Drop Serialize and Deserialize from a test typeIan Jackson2022-05-301-2/+1
| | | | | | | | | | These violate our rule that *built* structs ought not to be desr. But this is just in a test.
* | Add a few coverage-based tests to tor-config.Nick Mathewson2022-05-311-0/+13
|/ | | | There's nothing major here, but it does fill in a few gaps.
* Add a couple of "pub use" to make nightly rustdoc pass.Nick Mathewson2022-05-201-0/+3
|
* Merge branch 'typos-20220504' into 'main'eta2022-05-051-3/+3
|\ | | | | | | | | Fix typos (using the typos-cli tool). See merge request tpo/core/arti!486
| * Fix typos (using the typos-cli tool).Nick Mathewson2022-05-041-3/+3
| |
* | config derive attrs: Make builders serde, and validated structs notIan Jackson2022-05-051-11/+13
|/ | | | | | | | | | | | | | | * Builders additionally derive: Debug, Serialize, Deserialize. * Validated structs no longer derive: Serialize, Deserialize and all related attributes deleted. * As a consequence, all the `#[serde(deny_unknown_fields)]` are gone. That means that right now unknown fields are totally ignored. This is good for compatibility but poor for useability. Doing something better here is arti#417, in progress. * As a consequence, delete tor_dirmgr::retry::default_parallelism. (The default value was already duplicated into a builder attr.)
* list_builder: Add some xrefs about macro_rules limitationsIan Jackson2022-05-041-0/+8
| | | | | Apropos https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/474#note_2800481
* Fix typoNick Mathewson2022-05-041-1/+1
|
* list_builder: Provide VecBuilderIan Jackson2022-05-041-0/+41
| | | | This is for lists of plain types (non-builder types).
* list_builder: Use Educe to derive DefaultIan Jackson2022-05-041-1/+2
| | | | | | This allows us to use this with an item builder type which doesn't impl Default. (Obviously this only makes sense for items which aren't actually builders.)
* list_builder: Make helper capable of handling genericsIan Jackson2022-05-041-3/+15
| | | | | | | | It is Quite Vexing that we have to use [ ] rather than the < > around the generics, particularly given that we are also using [ ] to signal "this is arrayish". Signed-off-by: Ian Jackson <[email protected]>
* list_builder: Actually honour attributesIan Jackson2022-05-041-1/+4
| | | | | | The docs were a lie. $docs_and_attrs was missing from the expander. And add a note about how any supplied docs are handled.
* Fix typosNick Mathewson2022-05-041-2/+2
|
* Change builder list APIIan Jackson2022-05-041-113/+275
| | | | | | | | | | | | | | | | | | | | | | | | | | | The new API is (roughly) as discussed in https://gitlab.torproject.org/tpo/core/arti/-/issues/451 This is quite a large commit and it is not convenient to split it up. It contains the following changes: * Redo the list builder and accessor macros implemnetation, including docs and tests. * Change uses of define_list_config_builder. In each case: - Move the docs about the default value to the containing field. - Remove the other docs (which were just recapitulations, and are now not needed since the ListBuilder is no longer public). - Rewmove or replace `pub` in the define_list_builder_helper call, so that the builder is no longer public. - Change the main macro call site to use define_list_builder_helper. - Add a call to define_list_builder_accessors. * Make the module `list_builder` pub so that we have somewhere to put the overview documentation. * Consequential changes: - Change `outer.inner().replace(X)` to `outer.set_inner(X)` - Consequential changes to imports (`use` statements).
* Introduce ThingListBuilder::default_listIan Jackson2022-05-041-5/+8
| | | | | This removes a caveat from the API and will be convenient for what is coming.
* list-builder: Provide tests of all methodsIan Jackson2022-04-251-0/+31
| | | | | Because the macro output is private, if we miss one out of the tests, it doesn't fail due to dead code :-).
* list_builder: Allow the struct to not be pubIan Jackson2022-04-251-6/+6
| | | | | | | | | Really, we probably don't want any of these not to be pub, but it triggers "unreachable pub" in my test cases, and making it not pub by mistake seems not very serious, and likely to be noticed. Making the struct private in the test cases has the useful effect of checking that all the methods are tested.
* list_builder: Use $crate namespaced importsIan Jackson2022-04-251-3/+3
| | | | | | | I don't think we need to bother with things in the prelude, but doing it for serde and ConfigBuildError seems nice. Noticed while writing a test case.
* Document defaults for all the config listsIan Jackson2022-04-251-0/+1
| | | | | | | And add an imprecation in define_list_config_builder's doc comment do do so in future for other invocations of the macro. Add add the missing full stops.
* define_list_config_builder: Provide example of item_buildIan Jackson2022-04-251-0/+30
| | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/471#note_2798027