Skip to content

feat: allow accessing extra config#518

Merged
m4tx merged 4 commits intomasterfrom
extra-config
Mar 30, 2026
Merged

feat: allow accessing extra config#518
m4tx merged 4 commits intomasterfrom
extra-config

Conversation

@m4tx
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown

github-actions bot commented Mar 22, 2026

🐰 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
5,781.80 µs
(-3.70%)Baseline: 6,004.20 µs
7,247.80 µs
(79.77%)
json_api/json_api📈 view plot
🚷 view threshold
1,017.20 µs
(-2.42%)Baseline: 1,042.43 µs
1,223.43 µs
(83.14%)
nested_routers/nested_routers📈 view plot
🚷 view threshold
991.99 µs
(+3.40%)Baseline: 959.33 µs
1,115.96 µs
(88.89%)
single_root_route/single_root_route📈 view plot
🚷 view threshold
957.71 µs
(+3.95%)Baseline: 921.29 µs
1,078.56 µs
(88.80%)
single_root_route_burst/single_root_route_burst📈 view plot
🚷 view threshold
17,178.00 µs
(-2.69%)Baseline: 17,653.45 µs
21,121.38 µs
(81.33%)
🐰 View full continuous benchmarking report in Bencher

@codecov
Copy link
Copy Markdown

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.

@m4tx m4tx enabled auto-merge (squash) March 30, 2026 19:42
@m4tx m4tx disabled auto-merge March 30, 2026 20:23
@m4tx m4tx enabled auto-merge (squash) March 30, 2026 20:45
@m4tx m4tx disabled auto-merge March 30, 2026 21:14
@m4tx m4tx enabled auto-merge (squash) March 30, 2026 21:14
@m4tx m4tx merged commit 9490a28 into master Mar 30, 2026
37 of 40 checks passed
@m4tx m4tx deleted the extra-config branch March 30, 2026 21:39
@cotbot cotbot bot mentioned this pull request Mar 30, 2026
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.

3 participants