Skip to content

feat: allow accessing extra config#518

Open
m4tx wants to merge 1 commit intomasterfrom
extra-config
Open

feat: allow accessing extra config#518
m4tx wants to merge 1 commit intomasterfrom
extra-config

Conversation

@m4tx
Copy link
Member

@m4tx m4tx commented Mar 22, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 22, 2026 16:23
@github-actions github-actions bot added the C-lib Crate: cot (main library crate) label Mar 22, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enables consumers to read project-specific/unknown TOML configuration by capturing unrecognized keys into an extra map on ProjectConfig.

Changes:

  • Re-export toml from the crate root for easier access to toml types.
  • Add extra: toml::Table to ProjectConfig using #[serde(flatten)] and initialize it in the builder.
  • Add a unit test verifying extra config can be deserialized into a custom struct.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
cot/src/lib.rs Re-exports toml to support working with the new ProjectConfig::extra field.
cot/src/config.rs Adds ProjectConfig::extra to retain unknown TOML keys and tests access/deserialization.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

/// This is all the project-specific configuration data that can (and makes
/// sense to) be expressed in a TOML configuration file.
#[derive(Debug, Clone, PartialEq, Eq, Builder, Serialize, Deserialize)]
#[derive(Debug, Clone, Builder, Serialize, Deserialize)]
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing PartialEq/Eq from ProjectConfig is a breaking public API change (downstream code may rely on equality comparisons). If toml::Table prevents deriving Eq, consider restoring at least PartialEq (either via derive if supported, or via a manual impl PartialEq), or document this as a breaking change requiring a major version bump.

Suggested change
#[derive(Debug, Clone, Builder, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Builder, Serialize, Deserialize)]

Copilot uses AI. Check for mistakes.
pub use http;
#[cfg(feature = "openapi")]
pub use schemars;
pub use toml;
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-exporting the entire toml crate expands your public surface area and tightly couples your semver to toml’s API (any toml breaking change can become your breaking change). Prefer re-exporting only the needed items (e.g., toml::Table / toml::Value) or exposing them through your own types to keep the public API smaller and more stable.

Suggested change
pub use toml;
pub use toml::{Table, Value};

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

🐰 Bencher Report

Branchextra-config
Testbedgithub-ubuntu-latest
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
microseconds (µs)
(Result Δ%)
Upper Boundary
microseconds (µs)
(Limit %)
empty_router/empty_router📈 view plot
🚷 view threshold
6,437.50 µs
(+7.69%)Baseline: 5,977.82 µs
7,170.38 µs
(89.78%)
json_api/json_api📈 view plot
🚷 view threshold
1,081.50 µs
(+4.68%)Baseline: 1,033.12 µs
1,191.23 µs
(90.79%)
nested_routers/nested_routers📈 view plot
🚷 view threshold
1,010.90 µs
(+6.15%)Baseline: 952.34 µs
1,092.51 µs
(92.53%)
single_root_route/single_root_route📈 view plot
🚷 view threshold
973.62 µs
(+6.57%)Baseline: 913.60 µs
1,051.21 µs
(92.62%)
single_root_route_burst/single_root_route_burst📈 view plot
🚷 view threshold
18,500.00 µs
(+5.05%)Baseline: 17,610.86 µs
21,143.00 µs
(87.50%)
🐰 View full continuous benchmarking report in Bencher

@codecov
Copy link

codecov bot commented Mar 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
rust 90.00% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cot/src/config.rs 94.54% <100.00%> (+0.12%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-lib Crate: cot (main library crate)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants