Repository navigation
fix(types)!: allow initialized state and configuration without loading bounds - #110
Merged
Merged
Conversation
This was referenced Sep 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
已经初始化的 state 和配置仍被 builder 的整组方法、ConfigWrapper、GotchaContext 及其消费者要求实现 Default / serde,导致连接池或其他只能显式构造的状态需要提供没有实际意义的默认值。
现在可直接使用
Gotcha::from_state(value)或Gotcha::from_context(context)。运行时仅要求Clone + Send + Sync + 'static;配置没有 serde / Default 也可用于路由、State 提取、消息和任务,并进入 listen / listen_on / run。兼容说明:
with_state::<S>()等默认入口仍要求 Default,已初始化值使用新入口。GotchaApp::Config放宽为运行时约束,Deserialize 移到 config() / run() 方法;调用这两个方法的泛型代码需要显式添加A::Config: DeserializeOwned。这项方法约束也适用于自定义 config() 实现;无需反序列化的配置可以通过 build_router(context) 或 builder 的 from_context 使用。GotchaConfig 保留原有 trait 约束以兼容已有泛型代码,但框架运行时不再依赖它。验证包括外部消费者的真实 HTTP 提取与 Message 调用、无 Default/serde 的状态配置、各启动入口的 Send future、任务注册、仅 Deserialize 的加载和仅 Serialize 的序列化;既有 builder HTTP 组合测试改用无 Default/serde 的 context,并验证显式配置覆盖文件来源;另有一个测试确保提供 state 后不会调用未使用的 Default。README 和迁移文档已更新。
本地验证通过:
cargo test -p gotcha、cargo test -p gotcha --all-features(含 48 个通过的 doctest)、cargo test -p gotcha_macro、workspace all-features Clippy(-D warnings)、格式和 diff 检查。GitHub CI:11 项检查全部通过,验证提交
ea9ec6b6552e3c1394d6b54a2e6b6bc6725bb522。Closes #94